"Remember what Hashem did to Miriam" (Devarim 24:9). "If you wish to avoid tzora'as, don't speak lashon hara (as Miriam did)" (Rashi ibid.). The meraglim saw the punishment of Miriam, but failed to learn a lesson from it. For this reason, the story of the meraglim is found right after the story of Miriam (Rashi, Bamidbar 13:1). What lesson should the meraglim have learned from Miriam; their sin was not lashon hara, but motze shem ra on an inanimate object, Eretz Yisroel (13:32, see Onkelos)?
Miriam had discovered that Moshe abstained from relations with his wife, and related this fact to Aharon (Rashi 12:1). They said, "Hashem spoke to us too, yet we have not abstained from marital relations" (Rashi 12:2). For this Miriam was punished, even though she did not intend to speak badly of Moshe (Rashi 12:1). Hashem tells Miriam and Aharon that He had told Moshe to abstain (Rashi 12:8), He becomes angry and afflicts Miriam with tzara'as (12:9,10).
Miriam's basic mistake was the misinterpretation of the facts. She thought that Moshe had decided on his own to abstain, and she questioned his decision. In reality, however, Moshe was commanded to do so. Miriam's lashon hara was caused by her incorrect understanding of a situation that she had discovered.
The meraglim made a similar mistake. They described Eretz Yisroel as a land that devours its inhabitants (13:32). Wherever they went, they saw burials, so they assumed that it is extremely dangerous to live there (Rashi). In reality, Hashem arranged for numerous deaths and burials for the forty days the meraglim were in Eretz Yisroel in order to preoccupy the natives of the land with their mourning so that they should not detect the meraglim. At all other times, Eretz Yisroel was not dangerous at all.
The lesson that the meraglim should have learned from Miriam was the need to be certain about the facts before criticizing a person or a land. Miriam could have asked Moshe, or perhaps even Hashem, why he abstained. The meraglim could have asked Moshe, or perhaps even Hashem, why so many people died in Eretz Yisroel. Instead, based on their misinterpretation of the facts, they criticized Moshe and Eretz Yisroel, respectively.
The meraglim were punished by death (14:37) because they persisted in their attempt to enlist all of Am Yisroel in their campaign to besmirch Eretz Yisroel (14:36). The best efforts of Kalev and Yehoshua to refute them failed (13:30, 14:6-9) and led to threats to their lives (14:10).
Why didn't Moshe simply explain to the people that the numerous deaths in Eretz Yisroel were an aberration caused by Hashem to avoid the detection of the meraglim by its inhabitants? Apparently, once the negative impression of the land took hold in the people's minds, it was impossible to uproot. Such is the power of negative speech about a person or land, that it is difficult, if not impossible, to rectify.
We are commanded to remember what happened to Miriam. We dare not repeat the mistake of negative speech based on incorrect facts or interpretations, nor may we accept as absolute truth such negative reports. This mistake led to the destruction of the Mikdosh and the crying for generations (Ta'anis 29a). Only by correcting it can we be worthy of the ultimate redemption.