Having narrated the traitor's indignation at the kindness shown by the woman, the Evangelist now shows how our Lord put a stop to it. First, our Lord answers the unjust criticism Judas spoke against the woman; secondly, he rejects the spiritual reason Judas pretended to have (v 8).
He says, Let her alone, i.e., do not stop her. For it is well known that many good works are done which if our advice had been sought before they were done, we would not have advised that they be done, because something better could possibly have been done. Yet after they are begun, so long as they are good, they s...hould not be stopped. Thus, as Chrysostom says, before the woman had poured out the ointment, Jesus would perhaps have preferred that it be given to the poor, but now that it was done, he held back those who were trying to stop her, saying, Let her alone: "Do not prevent one who is able from doing good. If you are able, you also do good," as we read in Proverbs (3:27).
He adds, let her keep it for the day of my burial, foretelling both his approaching death and the kindness this woman was ready to do for him in his tomb if he had not precluded it by rising so soon, for as we read in Mark's Gospel (16:1): "Mary Magdalene," along with other women, "bought spices, so that they might go and anoint him." This is why he said, let her keep it for the day of my burial, not the identical ointment she used, but ointment of the same kind, in general or particular, or even a similar service. It is as though he were saying: Do not stop her from doing for me while I am alive what she will be unable to do for me when I am dead. For, as I said, she was prevented by the resurrection of Christ occurring so quickly. This is expressed in a clearer way in Mark (14:8): "She has anointed my body beforehand for burying."
But did she have foreknowledge of Christ's death? Not at all: for she did not understand what she was doing. Rather, she was moved to do it by a certain inner urge. It often happens that people are moved to do things that they do not understand, as in the case of Caiaphas, the high priest, who said, "You know nothing at all; you do not understand that it is expedient for you that one man should die for the people" (11:49). Things of this sort are called presages, because they take place before the event.
Source: Commentary on John