In Parshat Balak, we read the famous story of Bilam’s talking donkey. Bilam, on his way to curse the Jewish nation, is thrice visited by an angel with a drawn sword. While Bilam is unable to see the angel, his donkey can see it and avoids it by veering off the road. Bilam, unaware of the motivation behind his donkeys intransigence, beats his donkey each time. A miracle then happens, and Bilam’s donkey gains the power of speech. When the donkey asks Bilam why Bilam hit him the three times, the donkey uses an interesting expression, זה שלש רגלים, “these three times” (22:28). Rashi picks up on this oddity and comments that it is a hint to the following idea: How is Bilam expecting to curse a nation that observes the שלש רגלים and is consequently protected by Hashem? This idea seemingly has little to do with the story; however, it can be understood as alluding to a central idea in the Parsha.
If one looks at the focus of the Parsha, Bilam’s four blessings, something interesting emerges. The first blessing is basically an introduction to the rest. It is only two Pesukim long, and it contains very general content. The three remaining blessings each represent, in sequence, the שלש רגלים. The first is connected to the first of the שלש רגלים, Pesach, as the Pasuk says, קל מוציאם ממצרים, “It is God who brought them out of Egypt” (23:22). In the second of these main blessings, we have the celebrated Pasuk, מה טבו אהליך יעקב משכנתיך ישראל, “How goodly are your tents, Yaakov, and your dwelling places, Yisrael” (24:5). Chazal interpret משכנתיך as referring to the study of Torah. This connects to the second holiday, Shavuot, on which Chazal say the Torah was given. The third of these blessings talks mainly about the fate of various other nations. This is clearly connected to Sukkot. Sukkot is the time when we offer sacrifices on behalf of the other nations. An even clearer connection is seen in the Haftara of the first day of Sukkot, which discusses Messianic times and the final war. As Zechariah says, תהיה המגפה אשר יגף ה' את הגוים אשר לא יעלו לחג את חג הסוכת, “The same plague will come to pass with which Hashem will strike the nations that do not go up to celebrate the holiday of Sukkot” (14:18). Thus, we see that each of the שלש רגלים that we observe, in effect, takes its turn saving us from Bilam. First, they each attempt to prevent Bilam from going to Balak by sending an angel to stop him three times. Then, when that is ineffective, they each change one of his curses into a blessing that is reminiscent of the holiday in whose merit we are being saved.
This idea fits in with a comment made by Rabbi Zvi Grumet. Rabbi Grumet suggested that one of the reasons for the שלש רגלים is to take pagan holidays and dedicate and channel them to Hashem. In their merit, Hashem, in return, takes something pagan, sorcery, and transmutes it for Bnai Yisrael’s benefit.