The entire assembly of the Children of Israel arrived... the people settled in Kadesh, and Miriam died there and was buried there. And there was no water for the assembly, and they gathered together against Moshe and against Aharon.
Rashi explains why it was at this particular point that the Jews no longer had the Well to provide them with water.
ולא היה מים לעדה. מכאן שכל ארבעים שנה היה להם הבאר בזכות מרים - And there was no water for the assembly. From here we see that the entire forty years that the Jews spent in the desert they had the Well in the merit of Miriam.
We need to understand why Rashi felt the need to explicitly mention that ‘From here we see that the entire forty years they had the well in the merit of Miriam’; would it not have been sufficient for him to merely point out that ‘From here we see that they had the well through the merit of Miriam’. It would seem that Rashi was coming to reject a notion that the merit of Miriam did not provide the Well for the entire forty years, but rather for only a portion of the forty years. Nevertheless, we still need to understand the origin of this notion; that Miriam’s merit only provided the Well for part of the forty years and not for the entire forty years.
The Gemara in Bava Metzia (פו ע"ב) tells us the following.
בשכר שלשה זכו לשלשה וכו' בשכר יוקח נא מעט מים זכו לבארה של מרים וכו' – In reward for three things that Avraham did, the Jewish people merited three things... in reward for [Avraham telling the Angels whom he presumed to be simple wayfarers] “Let some water be brought” they merited the Well of Miriam.
The Maharsha questions this Gemara, for the Gemara in Taanis (ט ע"א) tells us, שלשה פרנסים טובים עמדו לישראל אלו הן משה ואהרן ומרים. ושלשה מתנות טובות ניתנו על ידם ואלו הן באר וענן ומן. באר בזכות מרים וכו', מתה מרים נסתלק הבאר שנאמר ותמת שם מרים וכתיב בתריה ולא היה מים לעדה וכו' – Three excellent leaders arose for the Jews; they are Moshe, Aharon and Miriam. And because of them three excellent gifts were bestowed upon the Jews; they are the Well, the Pillar of Cloud and the Man. The Well was provided in the merit of Miriam... When Miriam died the well disappeared, as it is says, ‘and Miriam died there’ and immediately thereafter it is written, ‘And there was no water for the assembly’.
From this Gemara it is clear that it was in the merit of Miriam, and not in the merit of Avraham, that the Jews merited to have the Well provide them with water.
The Maharsha thus explains that the merit of Avraham did indeed provide the Jews with water, but only for a portion of the forty years that they wandered in the desert, while it was the merit of Miriam that provided them with water for the entire forty years, and it was for this very reason that when Miriam died, the Well ceased providing them with water.
The reason why the Maharsha said that the merit of Avraham was only sufficient to provide the Jews for a short period, while the merit of Miriam was sufficient to provide for them for all the forty years, and not the other way around, is because the Gemara concludes and says ‘When Miriam died the well disappeared...’; the well disappearing as soon as Miriam died, clearly demonstrates that the entire time up until that point, it was in her merit that the well provided water to the Jews.
We can now understand why Rashi felt the need to expound on the words, ולא היה מים לעדה - And there was no water for the assembly, and to explicitly mention that היה להם הבאר בזכות מרים שכל ארבעים שנהמכאן - From here we see that the entire forty years that the Jews spent in the desert they had the well through the merit of Miriam. For as we explained, it was from these very words, that immediately after Miriam died there was no water for the assembly, that it is clearly inferred that the merit of Miriam didn’t just provide the Well for a short period, rather it provided the Well for the entire forty years.
זרע שמשון פרשתנו אות ו