The parsha of Shelach opens up with the story of the miraglim. Rashi notes that the previous parsha ended with the story of Miriam getting tzaras and being sent out of the camp because she spoke loshon harah about Moshe. Since this parsha begins with the miraglim, it implies that these two events are connected. But Rashi is bothered by the fact that they did not happen in chronological proximity. The events of the Korach rebellion were sandwiched in between.
Rashi explains that the Torah took these two events and juxtaposed them to teach us a lesson: Had the miraglim not been so wicked, they would have learned from what happened to Miriam, and that would have prevented them from saying their negative report about the land. However, says Rashi, “These wicked people saw what happened and didn’t learn from it.”