From the Rebbe’s explanation:
– In general, two reasons are offered for the sending spies by the Jews:
a) to prepare for conquest of Eretz Yisrael, to discover its roads and fortifications so that it would be easier to plan an attack.
b) To investigate the nature of the land, to inform the people of its positive qualities so that they will be eager to settle within it.
Moshe sent the spies primarily for the second purpose. He was confident that the conquest of Eretz Yisrael would be accomplished in a miraculous manner. He did, however, desire that they explore the land in order to tell the people of its positive qualities:
“To explore the land…. so that they shall see what kind of land it is… Whether it is good… whether it is rich…”
And therefore, he told them to bring back some of the fruit of the land, so the Jewish people would all be able to behold actual proof of the land’s positive qualities…
In contrast, in the time of Yehoshua, this was no longer necessary — for the spies sent by Moshe had already accomplished this objective.
This also explains why their mission was not secret.
It was made known to the Jews, for its entire purpose was to encourage them to desire to enter Eretz Yisrael. Furthermore, it was not hidden from the Canaanites. Since it was not directed at military objectives, the spies had no reason to obscure their identity and mingle among the local people to discover whether they were afraid of the Jews or not. Similarly, they were confident that just as the conquest of Eretz Yisrael would be carried out in a miraculous manner, so too, they would be able to carry out their mission in a miraculous manner without having to be concerned with the danger of apprehension.
Yehoshua’s sending of spies, in contrast, had a clear military objective, to discover the most practical way to conquer Jericho. For this reason, he sent the spies secretly, sending two and not twelve (for thus they could hide easier). Needless to say, the mission was not publicized to the Canaanites, and even to the Jewish people, it was not made known (lest word of it leak outside).
… Based on the above it can be explained that the spies’ mission did, in fact, accomplish its purpose.
They came back and told the people that Eretz Yisrael was a land of milk and honey and brought samples of the fine fruit that it produced. Thus the Jews knew from actual experience the positive qualities possessed by the land, and afterwards — albeit unfortunately, very many years afterwards — this knowledge allowed them to enter Eretz Yisrael with happiness and joy.
Furthermore, even immediately, in a spiritual sense, there was a positive dimension to their journey for the fact that Jews on a high spiritual level traveled through Eretz Yisrael was the first stage of the ultimate conquest of Eretz Yisrael. Thus their mission was part of the service of elevating the lower aspects of our material world.
The mission of the spies sent by Moshe also teaches us another lesson. A spy was sent from each tribe, because each tribe has a unique approach to the service of G‑d. For example, the service of the tribe of Yissachar centered on Torah study and that of Zevulun, on commercial activity the proceeds of which were used for tzedakah. Similarly, each other tribe had a unique path of service. In a correspondent manner, Eretz Yisrael is divided into twelve portions, one for each of the tribes, for the refinement of that portion of land is intrinsically related to the service of that particular tribe.
Accordingly, it would seem more appropriate for each of the leaders to have investigated the portion of Eretz Yisrael appropriate for his particular tribe. And yet, we find that the opposite was true.
All twelve spies traversed the entire land together.
This emphasizes how the individual service of every Jew is interconnected with that of our people as a whole, for — as an expression of the mitzvah of ahavas Yisrael — one Jew helps another carry out his service. Furthermore, through the collective efforts of the entire Jewish people (as represented by their leaders), the refinement of the world is carried out in a more complete and more elevated manner…
Based on the Rebbe’s talk on Shabbat Parshat Shelach, 26th Day of Sivan, 5751 (1991). Free translation.