It was becoming that Christ should wish to fast before His temptation....For since we are all in urgent need of strengthening ourselves against temptation...., by fasting before being tempted, He teaches us the need of fasting in order to equip ourselves against temptation. Hence the Apostle (2 Corinthians 6:5-7) reckons "fastings" together with the "armor of justice."
Thomas Aquinas, Summa Theologiae 3.41.3