After crossing the Yam Suf and leaving Egypt, Bnei Yisrael recite the Shirat HaYam. The Shirah begins with the words (Shemot 15:1) “Az Yashir Moshe UVnei Yisrael,” “Then Moshe and Bnei Yisrael sang.” The word “Az” is also used earlier in Shemot when Moshe says to Hashem (5:23) “UMeiAz Bati El Paroh,” “From the time I came to Paroh.” Moshe had just returned from Paroh for the first time. After being refused and seeing Paroh make Bnei Yisrael’s work harder, Moshe asks Hashem why he was sent if he is going to fail. The Midrash states that the reason the Shirah starts with “Az” is because Moshe began his first complaint to Hashem with the word “Az.” Utilizing this word to praise Hashem, Moshe is repenting for his past complaints. However, what does this message signify? Surely the Midrash is not merely pointing out a textual oddity.
Rav Chaim Soleveitchik provides an explanation. An ordinary person thanks God for rescuing him or helping him from a tough situation. He thanks Hashem only when faced with a bad situation and manages to overcome it. However, no ordinary person could be expected to thank Hashem for being put in a bad situation to begin with. Yet here, by Az Yashir, that is exactly what Moshe is doing. Moshe and Bnei Yisrael are thanking Hashem for the pain and suffering they had endured while in Egypt. Why would Bnei Yisrael thank God for suffering? When Hashem saved us from the torment of Egypt, all the nations of the world saw what occurred and recognized the might of Hashem. Therefore, our past suffering served a purpose; it facilitated the aggrandizing of Hashem’s name. This is what Moshe and Bnei Yisrael recognize and thank God for. In Moshe’s previous complaint to Hashem, he complained that he failed and Bnei Yisrael is still suffering under harsh slavery. Here, Moshe is rectifying that complaint by thanking Hashem for the slavery Bnei Yisrael went through. This is the true meaning of the Midrash. Moshe had the wisdom to realize that all that Hashem does is for a purpose, and we should be thankful for all that he does for us.