Moshiach will come when we do teshuvah. The Chasam Sofer zt'l asks, how can our teshuvah bring Moshiach? We think we do teshuvah, but to a large extent, Hashem does everything. Hashem puts the desire to do teshuvah into our hearts, and He helps us in the process. So, why do we deserve salvation? Why should we deserve Mashiach if we are not the ones who do the teshuvah?
The Chasam Sofer answers that our part is that we are happy with the teshuvah. Chazal revealed (end of Taanis) that Yom Kippur is one of the happiest days of the year because on Yom Kippur, we become cleansed from all our sins. Our happiness is our merit. One could theoretically be upset to be doing teshuvah because teshuvah means obedience to halachah and being restricted by the Torah's rules. But we want to do teshuvah and are happy that we are improving our ways. And for that, we deserve a reward.
It states (Tehillim 14:7), ישראל ישועת מציון יתן מי ישראל ישמח יעקב יגל עמו שבות 'ה בשוב . The Chasam Sofer explains that Dovid HaMelech asked ישראל ישועות מציון יתן מי, why do we deserve yeshuos? Although we do teshuvah, behold, עמו שבות 'ה בשוב, it is Hashem who is guiding us on the path of teshuvah. We aren't doing anything!
The answer is ישראל ישמח יעקב יגל. We are happy that Hashem is leading us on the path of teshuvah. For that, we deserve yeshuos and the upcoming redemption.
Hashem is also very happy on Yom Kippur because it is the day our aveiros are removed.
It states (Tehillim 139:16), בהם אחד ולו יצרו ימים, "Hashem created days, and one of the days is Hashem's." Tana d'Bei Eliyahu (ch.1) writes that this refers to Yom Kippur. Yom Kippur is "Hashem's day" because He is so happy that we are being cleansed of our aveiros.
The Tana d'Bei Eliyahu writes, "Hakadosh Baruch Hu gave this day to the Jewish nation with love and joy. It can be compared to servants who cleaned the king's palace, and when the king went outside and saw all the garbage that was discarded, he was pleased. This is what happens on Yom Kippur when Hashem forgives the sins of the Jewish nation. Hashem is very happy and says, 'Rejoice immensely because I am forgiving the sins of the Jewish people.'"
The Midrash (Tana d'Bei Eliyahu Zuta, end of ch.4) states, "Moshe went up on Har Sinai for forty days. On the fortieth day [Yom Kippur], the Jewish nation declared a fast day. The fast began at night, and in the morning, they went towards Har Sinai. They were crying as they approached Moshe, and Moshe was crying as he approached them. Their cries went up before Hashem, and Hashem's compassion was aroused, and He accepted their teshuvah. Hakadosh Baruch Hu said, ‘Bnei Yisrael! I swear by My name and throne that your tears will become tears of immense joy. This day will be a day for atonement for you, your children, your grandchildren, and for all generations.'"
