Upvote:4
The Bible tells us that after Jesus was baptised in the Jordan (Matthew 3:13) he was led by the Holy Spirit into the wilderness and fasted for forty days and nights. The purpose of this period of total fasting was to prepare him for the ministry that would change the world.
Satan offered Jesus alternatives to God’s plan, compromises that would satisfy His natural desires, and attacks upon His very identity as the Son of God (Matthew 4:3). Jesus used the Word of God, not His own strength, to defeat those temptations and remain victorious over sin. Jesus demonstrated that fasting can strengthen us spiritually when we use it to draw closer to God.
After Jesus’ fast, the devil left Him and “angels came and attended him” (Matthew 4:11). Luke 4:14 concludes the account of this testing time by saying, “Jesus returned to Galilee in the power of the Spirit.” He had conquered temptation and was ready to embrace the purpose for which the Father had sent Him. He would not rely on His humanity to perform miracles, deliver the oppressed, or defeat death. Fasting was a way to declare mastery over His human nature so that He would live every moment directed by the “power of the Spirit” (Luke 10:21).
Moses and Elijah took part in miraculous, forty-day absolute fasts. When Moses met God on the mountaintop to receive the tablets of stone, he ate no bread and drank no water (Deuteronomy 9:9). And, after Elijah defeated the prophets of Baal on Mt. Carmel, infuriating Queen Jezebel, Elijah fled for his life and spent forty days of fasting in the wilderness (1 Kings 19).
This type of fasting is quite different to the fasting described in Isaiah chapter 58. The nation of Israel was rebellious and had sinned against the LORD. Although they cried out for justice their hypocritical actions and injustice made a mockery of their fasting and apparent humility. That is why Isaiah had to rebuke them. Not so with Jesus, who was without sin and was the Son of God.
You ask what Jesus did during these 40 days in the wilderness. He fasted, he prayed and he resisted temptation. The following commentary (by Matthew Henry) regarding the events in the wilderness is helpful. It is a lengthy and detailed commentary, which concludes:
Christ was thus succoured after the temptation, [1.] For his encouragement to go on in his undertaking, that he might see the powers of heaven siding with him, when he saw the powers of hell set against him. [2.] For our encouragement to trust in him; for as he knew, by experience, what it was to suffer, being tempted, and how hard that was, so he knew what it was to be succoured, being tempted, and how comfortable that was; and therefore we may expect, not only that he will sympathize with his tempted people, but that he will come in with seasonable relief to them; as our great Melchizedec, who met Abraham when he returned from the battle, and as the angels here ministered to him.
Lastly, Christ, having been thus signalized and made great in the invisible world by the voice of the Father, the descent of the Spirit, his victory over devils, and his dominion over angels, was doubtless qualified to appear in the visible world as the Mediator between God and man; for consider how great this man was!
Source: https://www.christianity.com/bible/commentary.php?com=mh&b=40&c=4