“It happened when Paroh sent out the people...” Paroh cried “Vay” (woe) and he represents the evil inclination, the klippah, - for when the evil inclination is defeated by a person, the klippah is in pain.
“…Hashem did not lead them by way of the Plishtim…” After defeating the evil inclination, if a person coasts and discontinues his Avodas Hashem, he might arrive at the Land of Plishtim, meaning he will arrive to the material world.
“…because it was near…” means that when a person doesn't toil in Torah, it is near to certainty that he won't fight against the evil inclination.
”…when they see war and they will return to Egypt.” This means that Bnei Yisrael were susceptible of being imprisoned by the evil inclination, which is referred to as Egypt. This can happen if, once a person defeats the evil inclination, he does not elevate himself again, becoming accustomed to his “champion” state and forgetting about the battle. And, the next time he sees a war against the evil inclination, he will not be able to stand up against it and he will lose. Therefore, “Hashem did not lead them by way of the Plishtim.”
So, why did Hashem have to strengthen Paroh’s heart if he anyways regretted sending Bnei Yisrael away?
After Paroh received the plagues, he was in pain, just like the evil inclination when it is defeated. Therefore, just like with the evil inclination, Hashem strengthened Paroh’s heart (to take him out of his pain) to wage war against us, to ensure the continuity of the battle between a person and the evil inclination and ultimately lead the person to reach higher levels. Neither prayers nor Tzedaka will help against the evil inclination. Only Torah is the weapon against it. Like Chazal said (Succah 52b, Kidushin 30b): (Hashem said) “I created the evil inclination, and I created Torah as its remedy.”
Based on this, we can understand why before the splitting of the Dead Sea Hashem told Moshe (Shmos 14:15): “Why do you cry out to me? Speak to Bnei Yisrael and let them journey forth.” Moshe wanted to pray! What's wrong with prayer?
This is what Hashem meant: “At the time of war against the evil inclination, it's not the time to pray a lot, because I control him (if I control him, I sent him for a purpose. Prayer is not likely to help). I sent him to constantly battle against Bnei Yisrael so that they will not become lazy and be Mevatel Torah. Tell Bnei Yisrael to journey so that they will not stop learning.” A hint to this is in the word ויסעו (journey) which has the same numerical value as זה הלימוד לבדו (Only learning can do the job).
This is a fundamental idea for generations: any annulment of decree, overcoming or defeating the evil inclination comes through intense toil in Torah.
Not for nothing it says afterwards: “Amalek came and battled Bnei Yisrael in Refidim” and Chazal said (Bechoros 5b, תדא”ר כ”ג) that we were weakened in the aspect of Torah. (In Hebrew, “weakened” is “Rafu,” similar to Refidim) How come were we weakened? We saw so many miracles!?
Amalek is referred to as “the evil inclination.” Immediately after we had stopped our Avodas Hashem, Amalek attacked us with new and great powers in apathy (explained as taking away our passion for holiness). Why? Because after the splitting of the sea, Bnei Yisrael attained very high spiritual levels; so much so, that maidservants saw what the prophet Yechezkel couldn't see! We became known as the generation of De’ah (ability to differentiate, differentiating between Hashem and the garbage of this world), and we thought that the evil inclination would never be able to defeat us. So - we wanted to rest from our Avodas Hashem! For that, Hashem sent Amalek, so that we wouldn't get weak in Torah. The Or Hachayim Hakodosh says on the pasuk (Shmos 19:2) “ויסעו מרפידים” (they journeyed from Refidim): “they journeyed from weakness and prepared themselves to serve Hashem with pleasantness. A person must travel every day until the day of his passing without stopping (and remember) that as he gets stronger, the evil inclination also gets stronger.”
[והניראה בביאור הענין בטוב טעם ודעת,וארחי"ב באומ"ר ההקדמה עד לפני שער הביאור.]