Bamidbar20:12

וַיֹּאמֶר יְהוָה אֶל־מֹשֶׁה וְאֶל־אַהֲרֹן יַעַן לֹא־הֶאֱמַנְתֶּם בִּי לְהַקְדִּישֵׁנִי לְעֵינֵי בְּנֵי יִשְׂרָאֵל לָכֵן לֹא תָבִיאוּ אֶת־הַקָּהָל הַזֶּה אֶל־הָאָרֶץ אֲשֶׁר־נָתַתִּי לָהֶם׃

And the Eternal said to Moshe and to Aharon: "Because you did not believe in Me, to sanctify Me before the eyes of the children of Israel, therefore you shall not bring this assembly into the land which I have given them."

Bamidbar 20:12

וַיֹּאמֶר יְהוָה אֶל־מֹשֶׁה

Bamidbar / Numbers 20:12 · Pshat

Bamidbar 20:12

וַיֹּאמֶר יְהוָה אֶל־מֹשֶׁה וְאֶל־אַהֲרֹן יַעַן לֹא־הֶאֱמַנְתֶּם בִּי לְהַקְדִּישֵׁנִי לְעֵינֵי בְּנֵי יִשְׂרָאֵל לָכֵן לֹא תָבִיאוּ אֶת־הַקָּהָל הַזֶּה אֶל־הָאָרֶץ אֲשֶׁר־נָתַתִּי לָהֶם׃

And the Eternal said to Moshe and to Aharon: "Because you did not believe in Me, to sanctify Me before the eyes of the children of Israel, therefore you shall not bring this assembly into the land which I have given them."

Pshat פְּשָׁט

Before the whole people

A word said in private and the same word said before everyone are different deeds. Moshe had already spoken harsh words to the Eternal. Why did the punishment come only now?

Rashi: were it not for this sin, Moshe (Moses) and Aharon (Aaron) would have entered the land. Earlier Moshe said harsher words, but in private, while here it was before all Israel, and for the sanctification of the Name Scripture did not spare him. Had the rock given water at a word, the people would have said: all the more must we keep the word of the Eternal. Netziv: Aharon should have prayed, so he too shares this sin.

How Rashi and Haamek Davar explain it

Rashi Because you did not believe in Me

Scripture revealed that were it not for this one sin alone, they would have entered the land. It is said so that people should not say of them: as was the sin of the rest of the wilderness generation, who were destined not to enter the land, so was the sin of Moshe (Moses) and Aharon (Aaron). But were not the words "Shall flocks and herds be slaughtered for them" (Bamidbar / Numbers 11:22) harsher than this? But there it was in private, and Scripture spared him. Here, before all Israel, Scripture did not spare him, for the sanctification of the Name.

Rashi To sanctify Me

Had you spoken to the rock and it had brought forth water, I would have been sanctified before the eyes of the congregation, and they would have said: if this rock, which does not speak, does not hear and needs no sustenance, fulfils the word of the Omnipresent, all the more so we!

Haamek Davar Because you did not believe in Me

Had they acted through Torah and prayer, Aharon (Aaron) too would have prayed, for the Eternal said: "And speak to the rock." And since it was not done so, Aharon too is included in this sin. And although Aharon did not come to anger, still he let his hands drop where he should have acted in Moshe's place. See on this below, at verse 24.

Takeaway

"Shall flocks and herds be slaughtered for them" are Moshe's (Moses') words when the people asked for meat in the wilderness (Bamidbar / Numbers 11:21–22).
The Eternal said to Moshe and Aharon (Aaron): "And speak to the rock before their eyes" (Bamidbar / Numbers 20:8). The rock gave water after Moshe struck it twice with his staff (Bamidbar / Numbers 20:11).
The sanctification of the Name (קִדּוּשׁ הַשֵּׁם) is a deed after which people see the greatness of the Almighty.