"For Hashem did not lead them through the way of the land of the Philistines, as it was close, lest the nation regret when they saw war and return to Egypt."
These verses highlight an essential point about our journey when we left Egypt. Hashem could have brought us directly from the Nile Delta, where most Jews lived, through what we now call the Sinai desert and Gaza Strip, to what would become known as the Land of Israel. Such would have been the most direct route. However, Hashem did not choose this path. Instead, He took us across the sea to the other side (most likely in what is now Saudi Arabia) and we eventually came towards Israel from the South East instead of from the South West. Why choose such a complicated and circuitous route? The Torah answers in the verse quoted above. It was for fear of a lack of steadfastness in the face of war on the part of the Jews leaving Egypt.
However, this begs two questions. Firstly, war with whom? If it was war with the Egyptians, they pursued it anyway. The Jews wanted to retreat; however, Hashem dealt with that miraculously. Why was that a less likely outcome if that encounter had occurred on the shores of the Mediterranean instead of the Red Sea? If it was war with the Canaanites, that was coming anyway, and of course, when it arrived, the Children of Israel did indeed attempt a retreat.
Secondly, the Jews immediately encountered the Amalekites after crossing the Red Sea in war. That was a war with the residents of the Land of Israel and did not cause them to attempt to return to Egypt.
Rav Ya'akov Medan suggested a third group of people they might have had to battle with, the Philistines. Around the time of the Exodus from Egypt was a period called the Bronze Age Collapse. Many empires in the Near East collapsed at around the same time for reasons that are not fully understood. However, it is known and accepted that part of the problem was the mass migration of the "Sea Peoples" into those bronze age kingdoms. This migration was likely the result of environmental factors, including the eruption of a super-volcano that ended the Minoan civilisation in what we now call Crete. Rav Medan explained that the people whom the Jews might have to fight were the Sea Peoples, the ancestors of the Philistines. He suggests that the eruption of the volcano caused the darkness of the ninth plague and that for the Jews to take the coastal route would have exposed them to the early raids of those people who would become the Philistines. As these people caused the collapse of the Egyptian empire, they were very formidable. Additionally, there was no need for the Jews to fight them, at least at this early stage (though later in Jewish history, the Philistines and the Hebrews would come into regular conflict).
There is an essential lesson in this course of events. In the context of the miraculous Exodus from Egypt, Hashem could have waged war on behalf of the Jews against the Sea Peoples. Of course, the Sea People had not yet done anything to us, and the conflict was avoidable. As such, Hashem chose a different, more circuitous route. The route He chose avoided any need for battle. In our times, we should learn this lesson well. Sometimes, fighting and war are necessary, as in Israel now. However, we can often proceed without conflict. When that is a real option, it is always preferable.