I think Jesus is preparing his followers for what is coming. Jesus wants to get them ready. We know how all this turns out. Jesus makes his triumphal entry into Jerusalem, is betrayed, tried, convicted, and crucified and then is resurrected. His followers don’t know this like we know this.
Not that Jesus hasn’t been telling them. He keeps telling them and keeps telling them. They won’t listen and even respond in odd ways. Remember James and John a few weeks back? Jesus tells them the whole story of betrayal, trial and crucifixion and they respond not by recoiling in horror with weeping and gnashing of teeth but instead they ask him which of them can sit next to him in places of honor.
Jesus has been telling them he’s going to die and now he’s coming near that time. He needs to get their attention and while he probably wouldn’t have suggested pouring $40,000 worth of expensive perfume on his head he doesn’t prevent it either. And he makes a teaching moment out of it.