"And they said: Has the LORD then spoken only through Moses?" — for on account of this matter he separated from his wife. "Has He not spoken also through us?" — and I did not separate from my husband; and Aaron said: I too did not separate from my wife. "And the LORD heard." This teaches that they did not speak their words before any person in the world, and none heard their words but the LORD alone. And is this not a matter of kal va-chomer (an argument from minor to major)? If these, who spoke only concerning their own brother, were punished thus, then anyone who speaks against his fellow — how much more so shall he be punished!
Why Miriam and Aaron Were Punished for Speaking of Moses
Midrash Aggadah, Numbers 12:2
ויאמר הרק אך במשה דבר ה'. שעל דבר זה פירש מאשתו: הלא גם בנו דבר. ואני לא פירשתי מבעלי ואהרן אמר אני ג"כ לא פירשתי מאשתי: וישמע ה'. מלמד שלא אמרו דבריהם לפני אדם בעולם שלא שמע דבריהם אלא ה' בלבד והלא דברים קל וחומר ומנה אלו שלא דברו אלא באחיהם נענשו כך כל המדבר על חבירו על אחת כמה וכמה שהוא נענש: