After the St John the Forerunner baptized Jesus, he immediately left for the wilderness, and embarked upon a forty day fast, during which time he was tempted three times by the devil:
"Then was Jesus led up of the Spirit into the wilderness to be tempted of the devil. {2} And when he had fasted forty days and forty nights, he was afterward an hungered..." (Mat 4:1-2)
The Holy Evangelist Matthew wrote his gospel primarily in order to evangelize and inform the Jews, and therefore, he often carefully points out to his Jewish audience various fulfilled prophesies and typology which indicates Jesus is the Messiah of the Jews.
Before St Matthew recounts the Lords's fasting in the wilderness, he points attempts to show how our Lord the Son of God typologically reproduces the history of God's other "son," Israel, by linking the Lord's travel to and from Israel with the exodus of the Jewish people by quoting Hosea 11:1:
"When he arose, he took the young child and his mother by night, and departed into Egypt: {15} And was there until the death of Herod: that it might be fulfilled which was spoken of the Lord by the prophet, saying, Out of Egypt have I called my son."
The Messiah would fulfill all the commandments, which were not followed all too often in Israel&sq;s history. Their wandering for forty years in the wilderness was because of their disobedience and sins, but our Lord spent forty days in the wilderness in complete obedience to the commandments, and in particular, fasting without complaint, whilst the Jews in the wilderness incessantly complained about the food they ate.
Thanks to Gary Williams (Williamsg@ahec.edu), whose answer to this question on the Evang-Ortho mailing list ( see chrysostom.org/evang-ortho/ )forms the basis of the answer given here.