Matthew 26:6 Now when Jesus was in Bethany, in the house of Simon the leper, 7 There came unto him a woman having an alabaster box of very precious ointment, and poured it on his head, as he sat at meat. 8 But when his disciples saw it, they had indignation, saying, To what purpose is this waste? 9 For this ointment might have been sold for much, and given to the poor. 10 When Jesus understood it, he said unto them, Why trouble ye the woman? for she hath wrought a good work upon me. 11 For ye have the poor always with you; but me ye have not always. 12 For in that she hath poured this ointment on my body, she did it for my burial. 13 Verily I say unto you, Wheresoever this gospel shall be preached in the whole world, there shall also this, that this woman hath done, be told for a memorial of her.
Mark 14:3 And being in Bethany in the house of Simon the leper, as he sat at meat, there came a woman having an alabaster box of ointment of spikenard very precious; and she brake the box, and poured it on his head. 4 And there were some that had indignation within themselves, and said, Why was this waste of the ointment made? 5 For it might have been sold for more than three hundred pence, and have been given to the poor. And they murmured against her. 6 And Jesus said, Let her alone; why trouble ye her? she hath wrought a good work on me. 7 For ye have the poor with you always, and whensoever ye will ye may do them good: but me ye have not always. 8 She hath done what she could: she is come aforehand to anoint my body to the burying. 9 Verily I say unto you, Wheresoever this gospel shall be preached throughout the whole world, this also that she hath done shall be spoken of for a memorial of her.
John 12:1 Then Jesus six days before the passover came to Bethany, where Lazarus was which had been dead, whom he raised from the dead. 2 There they made him a supper; and Martha served: but Lazarus was one of them that sat at the table with him. 3 Then took Mary a pound of ointment of spikenard, very costly, and anointed the feet of Jesus, and wiped his feet with her hair: and the house was filled with the odour of the ointment. 4 Then saith one of his disciples, Judas Iscariot, Simon’s son, which should betray him, 5 Why was not this ointment sold for three hundred pence, and given to the poor? 6 This he said, not that he cared for the poor; but because he was a thief, and had the bag, and bare what was put therein. 7 Then said Jesus, Let her alone: against the day of my burying hath she kept this. 8 For the poor always ye have with you; but me ye have not always.
We might reasonably suppose that Mary wanted to reward Jesus in some way because he had raised her brother Lazarus from the dead.
She wasn’t aware that she was anointing him for his burial, because none of them understood that Jesus would shortly be killed.
The sum of three hundred pence was a year’s wages.
It demonstrates the magnitude of Mary’s gratitude and love for Christ.
John sets it in stark contrast against Judas’ love of money which would be his downfall.
I hope you find this helpful.