Why Moses wandered for 40 years? Why did he travel Israelites from the land of Egypt, the house of bondage lasted actually that long?
First, in the course of his journey Moses did not take the easiest possible route, which led along the Mediterranean coast to reach Canaan. The road led Israelites on a completely circuitous route through the desert.
According to some interpretations, Moses' choice was dictated by his desire to reach Sinai Mountains (Horeb). Mount Sinai, otherwise known as Mount Moses, is located entirely to the south Egyptin the southern part of the peninsula Sinai. To reach it, therefore, a journey into the country was needed.
As you know, the journey of the chosen people lasted a full 40 years. Some point out that these 40 years represent a symbolic length of life for the then generation. Some interpretations, referring to this symbolic length, suggest that it was intended as a complete generational change in Promised Land.
During the whole journey there were cyclic censuses of the population, and as we know, after reaching the destination there was not a single person left from the old generation. Thus, to the end of the journey arrived the generation of people completely free, who did not remember the old order, did not remember how lookedfor a life of slavery and from the moment of their birth they were free men. It was, as it were, a cleansing of the whole nation from the burden of slavery.
This is probably the simplest and also the most likely explanation of the matter. You could be yet to find in all this the punishment which the Lord imposed on the people for disobedience to himself israeli. Perhaps because of this, it somewhat condemned them to the hardships of a 40-year journey.