Bamidbar22:28

וַיִּפְתַּח יְהוָה אֶת־פִּי הָאָתוֹן וַתֹּאמֶר לְבִלְעָם מֶה־עָשִׂיתִי לְךָ כִּי הִכִּיתַנִי זֶה שָׁלֹשׁ רְגָלִים׃

And the Eternal opened the mouth of the she-donkey, and she said to Bilam: "What have I done to you, that you have struck me these three times?"

Bamidbar 22:28

וַיִּפְתַּח יְהוָה אֶת־פִּי

Bamidbar / Numbers 22:28

וַיִּפְתַּח יְהוָה אֶת־פִּי הָאָתוֹן וַתֹּאמֶר לְבִלְעָם מֶה־עָשִׂיתִי לְךָ כִּי הִכִּיתַנִי זֶה שָׁלֹשׁ רְגָלִים׃

And the Eternal opened the mouth of the she-donkey, and she said to Bilam: "What have I done to you, that you have struck me these three times?"

Pshat פְּשָׁט

The mouth of the she-donkey

Sforno: the Eternal gave the she-donkey the power to speak so that Bilam (Balaam) would remember that the gift of speech is given and taken by the Eternal, and would return in repentance. Kli Yakar: the she-donkey showed Bilam whom he resembles: prophecy is not natural to him either, and his mouth was opened only for a time, for the honour of Israel.

How Sforno and Kli Yakar explain it

Remez רֶמֶז

Three times

Rashi: "three times" (שָׁלֹשׁ רְגָלִים) hints at the three pilgrimage festivals (רְגָלִים): Bilam (Balaam) wants to uproot the people that celebrates them. Rabbeinu Bahya: three times it says that the she-donkey saw the angel, three signs, and the fourth sign is her speech.

How Rashi and Rabbeinu Bahya explain it

Drash דְּרָשׁ

Without a sword

The midrash: the Eternal opened the she-donkey's mouth to show that mouth and tongue are in His power. The she-donkey said to Bilam (Balaam): you cannot kill me without a sword, how then do you want to uproot a whole nation with your tongue? Having spoken, she died, so that she would not be worshipped and so as not to shame Bilam: if the Holy One, blessed is He, spares the honour of the wicked, all the more the honour of the righteous.

How Midrash Tanchuma explain it

Sod סוֹד

Three festivals against three traits

The Shem MiShmuel: the three traits of Bilam's (Balaam's) disciples, an evil eye, a haughty spirit and a wide soul, are envy, the craving for honour and desire, which take a person out of the world. The three festivals heal them: Pesach heals pride with the bread of poverty, Shavuot heals desire with the Torah, Sukkot heals envy with trust in the Eternal. That is why Bilam wanted to uproot precisely the three festivals.

How Shem MiShmuel explain it