Short answer
Jesus was hungry and tempted because he was a man, not God. The Bible says that "God cannot be tempted with evil". Yet Matthew says Jesus fasted forty days, grew hungry and was tempted by the devil three times. Hunger is a need. Paul, a Christian missionary of the first century, said God (﷾) is not worshipped with men's hands "as though he needed any thing". The devil asked Jesus to bow down to him. Jesus did not point to himself. He said, "Thou shalt worship the Lord thy God, and him only shalt thou serve." The Qur'an gives the same test. It says Jesus and his mother "had both to eat their (daily) food". Islam teaches that one who needs food is a servant of God (﷾), not God.
Full explanation
Hungry, and tempted by the devil
Matthew says the Spirit led Jesus into the wilderness to be tempted by the devil. After fasting forty days and nights, Matthew says, Jesus was hungry. James, a letter in the New Testament, says God (﷾) cannot be tempted with evil. Both cannot be said of the same God (﷾).
“Then was Jesus led up of the Spirit into the wilderness to be tempted of the devil.”
“And when he had fasted forty days and forty nights, he was afterward an hungred.”
“Let no man say when he is tempted, I am tempted of God: for God cannot be tempted with evil, neither tempteth he any man:”
Whom Jesus told to worship
The temptations also show whom Jesus worshipped. On the temple, the devil told Jesus to throw himself down. Jesus answered that no one may put the Lord his God to the test. On the mountain, the devil offered him the kingdoms of the world for his worship. Jesus sent him away with the command to worship the Lord God and serve Him only. He did not say "worship me".
“Then the devil taketh him up into the holy city, and setteth him on a pinnacle of the temple, And saith unto him, If thou be the Son of God, cast thyself down: for it is written, He shall give his angels charge concerning thee: and in their hands they shall bear thee up, lest at any time thou dash thy foot against a stone. Jesus said unto him, It is written again, Thou shalt not tempt the Lord thy God.”
“And saith unto him, All these things will I give thee, if thou wilt fall down and worship me.”
“Then saith Jesus unto him, Get thee hence, Satan: for it is written, Thou shalt worship the Lord thy God, and him only shalt thou serve.”
The One who needs nothing
Hunger is a need, and God (﷾) needs nothing. Philosophers explain why with the argument from contingency. Everything in the world depends on something else to exist. So there must be one being who depends on nothing, and so needs nothing. Paul told the Athenians that God (﷾) is not worshipped with men's hands as though He needed anything. Isaiah, a prophet of ancient Israel, says the Creator does not faint or grow weary. John says Jesus sat down at a well, wearied from his journey. Hunger and tiredness are needs.
“God that made the world and all things therein, seeing that he is Lord of heaven and earth, dwelleth not in temples made with hands; Neither is worshipped with men’s hands, as though he needed any thing, seeing he giveth to all life, and breath, and all things;”
“Hast thou not known? hast thou not heard, that the everlasting God, the Lord, the Creator of the ends of the earth, fainteth not, neither is weary? there is no searching of his understanding.”
“Now Jacob’s well was there. Jesus therefore, being wearied with his journey, sat thus on the well: and it was about the sixth hour.”
How Christians explain it
Christians answer from Hebrews, a letter in the New Testament. It says Jesus was tempted in all points as we are, yet without sin. They hold that he was hungry and tempted in his human nature, while his divine nature could not be.
“For we have not an high priest which cannot be touched with the feeling of our infirmities; but was in all points tempted like as we are, yet without sin.”
The Qur'an's test
The Qur'an says people are in need of Allah (﷾), and Allah (﷾) is free of all wants. It says Jesus and his mother both ate food. It also says that every messenger God (﷾) sent was a man who ate food and walked through the streets. So Jesus, who ate and grew hungry, was a servant of God (﷾), not God.
“O ye men! It is ye that have need of Allah: but Allah is the One Free of all wants, worthy of all praise.”
“Christ the son of Mary was no more than a messenger; many were the messengers that passed away before him. His mother was a woman of truth. They had both to eat their (daily) food. See how Allah doth make His signs clear to them; yet see in what ways they are deluded away from the truth!”
“And the messengers whom We sent before thee were all (men) who ate food and walked through the streets: We have made some of you as a trial for others: will ye have patience? for Allah is One Who sees (all things).”
Verse by verse
Hebrews 4:15 — Epistle to the Hebrews, chapter 4, verse 15
“For we have not an high priest which cannot be touched with the feeling of our infirmities; but was in all points tempted like as we are, yet without sin.”
Cited for
Jesus was tempted in every way as we are, yet without sin. He was tempted as a man, while as God he could not be tempted.
The response
Only a person is tempted; a nature is not. The one led into the wilderness is the only Jesus there is. If he is God the Son, then God (﷾) was tempted, and James says God (﷾) cannot be. James adds no exception for a human nature. Suppose a second, human "he" was tempted. Then Christ is two persons. That teaching was condemned at the Council of Ephesus in 431, a gathering of church leaders.
Where it lands — Hebrews confirms that Jesus was really tempted. James says God (﷾) cannot be. So the one tempted was not God.
Perspectives
Mainstream Christian
Jesus is fully God and fully man. He hungered and was tempted in his true human nature, without sin, while remaining God.
Christians read Hebrews 4:15 to mean that Jesus was tempted in his human nature while he remained God.
Rebuttal
Hebrews does say Jesus was really tempted. But a person is tempted, not a nature, and the one in the wilderness is the one Christians call God the Son. James says God (﷾) cannot be tempted, and adds no "except in a human nature".
The Islamic perspective
Jesus was a man and a prophet who hungered, was tempted, and worshipped God (﷾) alone. God (﷾) is never tempted and needs nothing.
The Bible says God (﷾) cannot be tempted with evil.
Matthew records that Jesus was led into the wilderness to be tempted by the devil. He was hungry after fasting forty days.
When the devil asked for worship, Jesus told him to worship the Lord God and serve Him only.
Paul says God (﷾) is not worshipped with men's hands as though He needed anything.
Isaiah says the Creator does not faint or grow weary, and John says Jesus was wearied by his journey.
A being that exists by itself needs nothing, because anything that needs something depends on something else.
The Qur'an teaches that Jesus and his mother ate food, as every messenger God (﷾) sent did. This shows they were created servants.