The account in the Bible book of Exodus gives the answer. Chapter 13 verse 17 begins to explain the wilderness detour, and I quote from the New Living Translation:
"When Pharaoh finally let the people go, God did not lead them along the main road that runs through Philistine territory, even though that was the shortest route to the Promised Land. God said, 'If the people are faced with a battle, they might change their minds and return to Egypt.' So God led them in a roundabout way through the wilderness toward the Red Sea."
They themselves were totally inexperienced in warfare, so when they saw the Egyptian army chasing after them while they were trapped by the Red Sea, they were panic stricken and knew they could not even defend themselves. That was when they witnessed God fighting on their behalf, in spectacular and miraculous fashion! God displayed his glory and they did not have to lift a finger - Moses only had to lift his arms! Thereafter, they experienced God's miraculous provisions of food and water in the wilderness. God was teaching them to trust him. Yet chapter 16 verse 2 describes how they complained at God, a developing pattern as time went by.
Even by the time God knew they were ready to do battle to enter the Promised Land, it was their continued lack of trust (faith) in him that caused God to send them back into the wilderness, for forty years! The ten spies had spent forty days checking out the land of Canaan, with only Joshua and Caleb urging the nation to enter. So God decreed that for every day spying, they would spend a year in the wilderness. The reason for that length of time was for the generation who lacked faith to enter to die off. Only their children (plus faithful Joshua and Caleb) finally entered the Promised Land. Read Numbers 14 vss 26 to 35.
It wasn't Moses who directed the routes for their wilderness wanderings. The pillar of cloud by day and of fire by night determined where they were to go and for how long they had to stay camped. This was God directing the route. See Exodus 13 vss 21 to 22.
Catholic scholar Benedict Schwank agrees with the biblical account of this early period in Israel's desert wanderings. He writes, "In the wilderness the tribes, who were once in bondage, feel themselves to be the chosen people of God. Henceforward Israel is conscious of being the vassal people of Yahweh... From now on Israel and Yahweh are united by a sacred covenant... Henceforward this practical monotheism sets Israel apart from all other peoples of the Near East. Although it is uncertain which route the people took at the exodus from Egypt, there are sound reasons for believing that the crossing of the Red Sea took place at the southern end of the Salt Lakes." (Encyclopedia of Theology pp 1096-7, edited by Karl Rhaner, Burns & Oates, 1981)