"And the children of Israel did" (Judges). Rabbi Simon said: Not everyone who wishes to recite a song may recite a song; rather, only one for whom a miracle has been performed. And anyone for whom a miracle has been performed and who recites a song, it is known that he is forgiven for all his sins and becomes a new creation. Israel, when a miracle was performed for them and they recited a song, their sins were forgiven, as it is said, "And Moses brought Israel onward" (Exodus 15:22) - that he moved them away from their sins. And likewise you find with Deborah and Barak, for whom a miracle was performed and who recited a song. And how do we know that their sins were forgiven? Rabbi Aivu said in the name of Rabbi Abba: Everywhere it says, "And the children of Israel again did evil," but here it is written, "And the children of Israel did" - the beginning of doing. And where are the things they did beforehand? Rather, the Holy One, blessed be He, forgave them for what they had done in the past. And likewise you find with David, for whom a miracle was performed and who recited a song. And how do we know that all his sins were forgiven? For it is written after the song, "Now these are the last words of David" (II Samuel 23:1). And where are the first ones? Rather, this teaches that the Holy One, blessed be He, forgave him.
Song After a Miracle That Erases Sins and Renews the Soul
Yalkut Shimoni on Nach 60:1
ויעשו בני ישראל. אמר רבי סימון לא כל מי שירצה לומר שירה אומר שירה אלא כל מי שנעשה לו נס וכל מי שנעשה לו נס ואומר שירה בידוע שמוחלין לו על כל עונותיו ונעשה בריה חדשה. ישראל כשנעשה להם נס ואמרו שירה נמחל להם עונותיהם שנאמר ויסע משה את ישראל שהסיעם מעוונותיהם. וכן אתה מוצא בדבור וברק שנעשה להם נס ואמרו שירה. ומנין שנמחלו עונותיהם, רבי איבו בשם רבי אבא בכל מקום הוא אומר ויוסיפו בני ישראל לעשות הרע, וכאן כתיב ויעשו בני ישראל תחחלת עשייה והיכן הם מה שעשו לשעבר אלא מחל להם הקב"ה מה שעשו לשעבר, וכן אתה מוצא בדוד שנעשה לו נס ואמר שירה ומנין שנמחלו לו כל עונותיו דכתיב בתר שירה ואלה דברי דוד האחרונים והיכן הם הראשונים אלא מלמד שמחל לו הקב"ה: