The Torah uses the word וַיְהִי, an expression of pain, when Par’oh sent the עָם out of Mitzrayim. Hashem did not redeem the mixture of other nations from Mitzrayim, He only wanted His nation to leave Mitzrayim. It was indeed a painful experience that even those who weren’t included in Klal Yisroel left Mitzrayim. They caused problems for Klal Yisroel at every step. Par’oh sent them along with Klal Yisroel in order that they persuade Klal Yisroel to return to Mitzrayim one day.
The Torah continues with the sad story of the long sojourn in the desert, which was due to their not going the short route. וְלֹא נָחָם אֱלוקים דֶרֶךְ אֶרֶץ פְלִשְתִים – Hashem did not lead them on the shorter route. All this is part of the pain that was experienced when they left Mitzrayim. The reason they had to go that route was כִּי קָרוֹב הוּא – because it was close. The Ohr Hachaim explains that the Erev Rav was too close to the other side, they weren’t completely attached to the holy side. They could cause significant damage to Klal Yisroel, and they needed some time in the desert.