A failed mission that paved the way
meraglim · shlichus · Yehoshua · hashgachah · purpose
במדרש מקצה רגלים כו'.
In the Midrash: "He cuts off the feet…"
The Midrash applies the verse "He cuts off the feet" (Mishlei 26:6) to the sending of the meraglim (spies); the Sefas Emes will explain how their mission nonetheless served a purpose.
נראה כי לא הי' לבטלה שליחות המרגלים כי לא הי' באפשרי לשלוח רק אותם וקלקלו והי' נצרך אח"כ לשלוח שנית בימי יהושע אבל הועיל שליחותם שיוכל אח"כ לשלוח:
It appears that the mission of the meraglim was not in vain, for it was only possible to send those particular ones; they ruined it, and it was therefore necessary afterward to send a second time in the days of Yehoshua — but their mission accomplished this, that one could send again afterward.
Even though the spies failed, their being sent was not pointless: only they could be sent at that moment. Their failure made a later mission necessary in Yehoshua's day, yet that very first sending opened the way for the second one to succeed.
Summary: Although the meraglim ruined their mission, their being sent was not for nothing — only they could be sent then, and their sending made possible the later, successful mission in the days of Yehoshua.