The Rambam teaches that leaders of the community call a public fast (ta’anit tzibbur) in times of crisis or to mark a tragic event in Jewish history (Hilchot Ta’anit, 1:1-2).The goal is repentance. Fasting not only removes the distraction of food but reminds us that we should always be dedicated to a higher purpose than simply our physical needs.
On the rebuilding of the Second Temple in sixth century BCE, the people asked the prophet Zechariah if there still was any reason to fast on the days marking the destruction of the First Temple and the loss of Jewish independence. Zechariah answered cryptically that those fasts “shall become occasions for joy and gladness, happy festivals for the house of Judah; but you must love honesty and integrity” (Zechariah 8:19).
The sages learn from this that in times of persecution and lack of peace, we must fast on days marking the destruction of the Temple. But in times of peace and freedom, we do not fast – except for the Ninth of Av, which remains until the Messiah comes.
What about today? Do we live in a time of peace and freedom? According to the Shulchan Aruch, the fasts in memory of the Temple (except the Ninth of Av) are optional today (Orach Chaim 550). But because the community has taken them on, we keep them.