After the death of Miriam, the well, which had supplied the Jewish people with water during their travels in the wilderness in her merit, disappeared and the Jews had nothing to drink. They began to complain to Moshe and Aharon, questioning why they had brought them to die in the wilderness together with their animals. Moshe and Aharon went to the Mishkon to seek guidance from Hashem, and Hashem responded by instructing Moshe to speak to a rock, which would produce water for the thirsty Jewish people. Although Moshe did indeed bring forth water from the rock, Hashem informed Moshe and Aharon that they had sinned in not believing in Hashem and sanctifying His name, and as a result, they would not be permitted to enter the land of Eretz Yisroel.
Because the Torah is so vague in describing their sin, the meforshim throughout the generations have offered numerous explanations as to the precise nature of their error. In his Sefer HaIkrim (4:22), Rav Yosef Albo offers an original explanation about the nature of Moshe's sin. He suggests that as soon as Moshe and Aharon realized that the Jewish people were thirsty, instead of approaching Hashem for instructions, they should have sanctified Hashem's name by proactively approaching the rock and producing water from it, as Hashem fulfills the requests of the righteous. Their decision not to do so reflected a lack of trust in Hashem, and for that they were punished.
However, the Meshech Chochmah points out that in all of the miracles that Moshe performed, such as splitting the Yam Suf, the mon, and the slov [quail], he always waited for explicit instructions from Hashem and never initiated them on his own. This stands in stark contrast to other Neviyim, such as Yehoshua when he ordered the sun to stand still (Yehoshua 10:12) and Eliyohu at Har HaCarmel (Melochim 1 18), who did perform miracles without any prior command from Hashem. Why did Moshe conduct himself differently in this regard, and why was he punished here for acting in accordance with his customary approach?
Rav Meir Simcha explains that Moshe's level of nevuah was unique in that he was able to speak to Hashem with all of his faculties intact, just as one would speak to another person, whereas other Neviyim were frightened and overwhelmed by the experience (Rambam, Hilchos Yesodei HaTorah 7:6). Because it was clear to all that great as they were, the other Neviyim were still mere mortals and did not possess any abilities to change nature on their own, there was no risk for them to proactively perform miracles. On the other hand, had Moshe done so, there was a possibility that some onlookers would erroneously attribute G-d-like powers to him. To prevent this from happening, Moshe consciously decided to perform miracles only when he was explicitly commanded by Hashem to do so.
Interestingly, there was one exception. When Korach challenged the leadership of Moshe and Aharon, Moshe responded by designing a miraculous test to prove that he had Divine support. Without any instructions from Hashem to do so, Moshe announced that his legitimacy would be established by the earth miraculously opening up and swallowing Korach and his followers alive, which is indeed what happened (16:28-34). Once Korach had publicly argued that all Jews were equally holy and there was nothing unique about Moshe (16:3), Moshe was no longer concerned that people would mistakenly ascribe to him Divine status.
However, now that Moshe had demonstrated a willingness to deviate from his customary procedure and to call on Hashem to miraculously resolve a difficult situation, his refusal to similarly do so when the people were crying out for water left him susceptible to an argument that he was more concerned about his own reputation than he was about the nation's well-being. This was a tremendous desecration of Hashem's name, and for this he was punished harshly.
Although consistency in performing miracles is not an issue with which most of us struggle, this lesson is still relevant to each of us. It is human nature to prioritize our own needs and to address them with alacrity. In doing so, we must be cognizant of a parallel obligation to show the identical diligence in standing up for Hashem's honour and assisting our fellow man. (R’ Ozer Alport)