from the Summa of Saint Thomas Aquinas ( III, q. XLI, a. 1 )
"Jesus was led by the Spirit into the desert to be tempted by the devil." Matt. IV, 1
Our Lord wished to be tempted; first that He might strengthen us against temptations. Hence Saint Gregory says: “It was not unworthy of our Redeemer to wish to be tempted, who came also to be slain; in order that by His temptations He might conquer our temptations, just as by His death He overcame our death.”
Secondly, that we might be warned, so that none, however holy, may think himself safe or free from temptation. Wherefore also He wished to be tempted after His baptism, because, as Saint Hilary says: “The temptations of the devil assail those principally who are sanctified, for he desires, above all, to overcome the holy. Hence also it is written (Sirach 2): ‘Son, when thou comest to the service of God, stand in justice and in fear, and prepare thy soul for temptation.’ ”
Thirdly, in order to give us an example: to teach us, to wit, how to overcome the temptations of the devil. Hence Saint Augustine says that Christ “allowed Himself to be tempted" by the devil, "that He might be our Mediator in overcoming temptations, not only by helping us, but also by giving us an example.”
Fourthly, in order to fill us with confidence in His mercy. Hence it is written (Hebrews 4:15): “We have not a high-priest, who cannot have compassion on our infirmities, but one tempted in all things like as we are, without sin.”
As stated above, Our Lord of His own free-will exposed Himself to be tempted by the devil, just as by His own free-will He submitted to be killed by His members; else the devil would not have dared to approach Him. Now the devil prefers to assail a man who is alone, for, as it is written (Ecclesiastes 4:12), "if a man prevail against one, two shall withstand him." And so it was that Christ went out into the desert, as to a field of battle, to be tempted there by the devil. Hence Ambrose says that “Christ was led into the desert for the purpose of provoking the devil. For had he,” i.e. the devil, “not fought, He,” i.e. Christ, “would not have conquered.” He adds other reasons, saying that “Christ in doing this set forth the mystery of Adam's delivery from exile,” who had been expelled from paradise into the desert, and “set an example to us, by showing that the devil envies those who strive for better things.”
Also, it was becoming that Christ should wish to fast before His temptation. First, in order to give us an example. For since we are all in urgent need of strengthening ourselves against temptation, as stated above, by fasting before being tempted, He teaches us the need of fasting in order to equip ourselves against temptation. Hence Saint Paul (2 Corinthians 6:5-7) reckons “fastings” together with the “armor of justice”. Secondly, in order to show that the devil assails with temptations even those who fast, as likewise those who are given to other good works. And so Christ's temptation took place after His fast, as also after His baptism. Hence since rather Chrysostom says: “To instruct thee how great a good is fasting, and how it is a most powerful shield against the devil; and that after baptism thou shouldst give thyself up, not to luxury, but to fasting; for this cause Christ fasted, not as needing it Himself, but as teaching us.”
Thirdly, because after the fast, hunger followed, which made the devil dare to approach Him. Now, when “Our Lord was hungry,” says Saint Hilary, “it was not because He was overcome by want of food, but because He abandoned His manhood to its nature. For the devil was to be conquered, not by God, but by the flesh.” Wherefore Chrysostom too says: “He proceeded no farther than Moses and Elias, lest His assumption of our flesh might seem incredible.”