According to Google Maps to walk from Cairo to Jerusalem today would take less than 150 hours. As we know at the time of the Exodus, it took the Israelites forty years!
The Torah tells us at the beginning of the portion that G-d did not lead the Israelites to their destination via the coastal route (Derech Eretz Plishtim), via the land of the Philistines even though it was the shortest route in those days. The reason given? “Lest they see war and want to return to Egypt.”
Instead, the people go to the Red Sea and panic when they see the Egyptian chariots. They wander through the desert and, repeatedly, when they don’t find food or water, they complain and want to return to Egypt. A year later, when Moses sends out spies, the people want to return to Egypt as they don’t think they can defeat the Canaanites. In other words, the prospect of war makes the Israelites despair and want to return to Egypt. What has therefore been achieved by taking them through a longer route?
Many commentators explain that when the Israelites left Egypt the slave mentality that they had absorbed was deep in their psyche. As the Sfat Emet (d. 1905) once observed, “It took one day to take Israel out of Egypt; it took forty years to take Egypt out of Israel!”
Perhaps the answer lies in the difference between desire and opportunity. Had G-d taken the Israelites by the shorter route, then, when a crisis would have arisen, not only would they have had the wish to return to Egypt, but, more importantly, they would have had the means to do so, since the return route was just a few days journey away. By miring them in the Sinai desert, G-d ensured that handicaps for organising a march back to Egypt were simply too great. In due course a new generation was born that did not have to carry the psychological baggage of the burden of slavery and were able to enter the Promised Land.