There are several passages that suggest an answer; in particular Deuteronomy 8:2–3:
2 And you shall remember the whole way that the Lord your God has led you these forty years in the wilderness, that he might humble you, testing you to know what was in your heart, whether you would keep his commandments or not. 3 And he humbled you and let you hunger and fed you with manna, which you did not know, nor did your fathers know, that he might make you know that man does not live by bread alone, but man lives by every word that comes from the mouth of the Lord. [ESV]
This passage reveals two things: first, that God's overall purpose for the wandering in the wilderness was to test the Israelites and humble them, for their own good (cf. Deut. 8:16). And second, that through hunger specifically they would learn that "man lives by every word that comes from the mouth of the Lord." (cf. Matt. 4:4)
This makes sense given the attitude of the Israelites recorded in Exodus 17 as they have just been fed with manna and now want water. Despite being led out of Egypt and through the Red Sea, they doubted God:
And he called the name of the place Massah and Meribah, because of the quarreling of the people of Israel, and because they tested the Lord by saying, “Is the Lord among us or not?” (Ex. 17:7, ESV)
So, based on these passages, we could conclude that God allowed Israel to undergo these trials to promote their spiritual development and teach them to rely on God. They repeatedly failed these tests: instead of trusting God's provision, the Israelites complained and doubted God.