“And there was no water for the congregation.” – Numbers 20:2
The well that provided water for the B’nei Yisrael in the desert, and “followed” them throughout their journeys, did so upon the merit of Miriam, the sister of Moses and Aaron. She was a prophetess, and a coleader with Moses and Aaron. “For I brought you out of the land of Egypt, and redeemed you from the house of slavery; and I sent before you Moses, Aaron, and Miriam” (Micah 6:4). However, when Miriam passed away, “there was no water for the congregation” (Numbers 20:2). Miriam was a righteous person; so, in her merit the water had been provided to the Children of Israel for thirty-nine years. When she passed away, the well dried up.
The Sages ask why the mentioning of Miriam’s death occurs right after the description of the chukat (decree) of the parumah adumah (red heifer). The answer given is to exemplify that just as an offering brings atonement, so does the death of a righteous person bring atonement for the people (Mo’ed Katan 28a). Additionally, concerning the death of Aaron, who was not permitted to enter the land of Canaan: “Aaron shall be gathered to his people” (Numbers 20:4), his death also brought atonement.
As commentary futher explains, “Wherefore is [the account of] Aaron’s death closely followed by [the account of the disposal of] the priestly garments? [to inform you] that just as the priest’s vestments were [means to effect] atonement, so is the death of the righteous [conducive to procuring] atonement” (Talmud: Moed Katan 28a, Soncino edition, www.halakhah.com). Therefore, both the deaths of Miriam and Aaron, because they were righteous persons, atoned for that generation.