What does Matthew 26:12 mean?
The disciples had expressed disapproval for a woman's extravagant act of anointing Jesus with oil (Matthew 26:6–9). "Why this waste?" they asked. The price of the ointment was nearly a year's wages, assuming the description in John 12:1–11 is of the same event. Why not sell the ointment and feed some hungry people? This is not a completely unreasonable concern; the disciples are aware of the poor around them and Jesus' commands to care for others.Jesus has corrected them for attempting to rebuke the woman. He calls her act of devotion "beautiful" (Matthew 26:10) thing. It's not that giving to the poor is not important. Instead, Jesus emphasizes that His time with them in person is short. This is the only opportunity she will ever have to make this specific gift.
Now He adds another detail to the meaning behind this bold anointing. Whether this woman, likely Mary (John 11:1), understood it or not, the ointment she poured over Jesus has served to prepare Him for His burial. Anointing the body of someone who has died was an important part of the burial custom of the time. Jesus knew He would soon be crucified, as He had repeatedly told the disciples. More was going on in this anointing than extravagant hospitality. This woman was participating in the preparations for the Messiah's death and burial.
This forms an indirect prophesy of sorts. There will be no time to properly anoint Jesus between His death and burial (Luke 23:52–56). The event Matthew describes here is something of a provision of God, seeing to that detail. After Jesus' burial, several women will bring spices to further anoint His body only to find Him missing (Mark 16:1–5).