As Israel left Egypt, God had completely spoiled the empire. The ruler was dead and all of his army. The land was desolate and would take hundreds of years to recover. Yet their idols and houses and temples were still there, still intact. It is very possible, even likely, that Israel considered heavily going back to Egypt to rule over the broken Egyptian people and take the nice homes and live in ease. It is very possible that some among them were even making such plans as they stirred up the congregation to murmur. Yet the manner of the exodus assured that such was not possible.
Their route presented the first obstacle. God took them “the short direction” through the Red Sea. A route they could not possibly hope to retrace. The trip back, which would be unknown to most of them who were city folk, would take much longer and require them to travel back down to southern Arabia and then across through Ethiopia or to go by boat both of which would be a big deal with only a small percentage of the population capable of achieving.
Next, God gave them several experiences with hunger and thirst, intentionally I believe, to help them remember they were in a wilderness. These experiences, and his miraculous solutions to them, showed them that he was going to care for them if they proceeded. At the same time these experiences would have shown them their absolute dependence on God and the futility or likely disastrous affects of abandoning God and trying to go back on their own. If they had not experienced the great want, they would not realize the great gift they were receiving and they would not have realized how dangerous any other course but following their God would be for them. Again, realizing the difficulty of surviving in the wilderness would deter their attempting to return.
I believe that this few periods of great suffering, a few days without food in one instance before the miracle of manna, and a few days without water once they crossed over into Sinai, were both crucial experiences in helping Israel really learn to follow God and leave all other ideas behind. I believe it helped create the needed commitment to the experience they were having to carry on so God could tutor them in becoming a holy people and being capable of blessing the world as Abraham had been promised.
I believe God does similar things for us in our lives.