Exodus 13:17 “Now when Pharoah let the people go, God did not lead them by way of the land of the Phillistines, although it was nearer…”
Shemos Rabbah (20:11) explains that members of the tribe of Ephraim were overly anxious in their anticipation of the Ge’ulah, the Redemption from Egypt, and miscalculated when it was to occur. They were thirty years too early. However, confident in their own calculation, despite opposition from all of their fellow Jews, they took it upon themselve to leave Egypt and enter the promised land. They were all killed. Their bones littered the direct route to Israel, through Phillistine land, and God did not want the other Jews to have to see those bones. That is why he took them on a different route.
For practical application of this midrash about the disastrous repercussions of even slightly miscalculating the Redemption, see my introduction to Kuntres Bikores Ha-Ge’ulah.