The Shiras HaYam (Song of the Sea) in Parshas Beshalach focuses primarily on the miracles of the splitting of the Yam Suf. But it also contains three references to the Beis HaMikdash. One of the first lines of the shirah is "Zeh Keili v'anveihu (15:2)" which Targum Onkelos translates, "This is my G-d and I will build him a Mikdash." Later, the posuk says, "With Your kindness, You have guided this people that You have redeemed; You led with Your might to Your holy dwelling place (15:13)" Both Targum Yonason and the Ramban explain that "Your holy dwelling place" refers to the Beis HaMikdash. And finally, the shirah concludes, "You will bring them and implant them on the mountain of your inheritance, the foundation of your dwelling place that You, Hashem, have made - the Mikdash, Hashem, that Your hands established. (15:17)" Once again, a reference is made to the Beis HaMikdash. What is the connection between the Shiras HaYam and the Beis HaMikdash?
In his introduction to Sefer Shemos, the Ramban calls Shemos the book of galus and ge'ulah (exile and redemption). But how is that name appropriate? After all, Sefer Shemos discusses not only the suffering of Klal Yisrael in Mitzrayim and their redemption from slavery, but also the giving of the Torah and the building of the Mishkan. At first glance, these events seem unrelated to yetzias Mitzrayim. If so, why are they included in Sefer Shemos?
The answer, says the Ramban, is that even after Klal Yisrael left Mitzrayim, their redemption was incomplete until they received the Torah at Har Sinai and built the Mishkan, and Hakadosh Baruch Hu caused his Shechinah to dwell amongst them. Only then did they return to the lofty level of the Avos who enjoyed a special closeness to the Shechinah, and that is when Klal Yisrael achieved a full redemption.
In a similar vein, we conclude the beracha of Asher Ge'alanu in the Haggadah of Pesach by asking for the rebuilding of the Beis HaMikdash where "we will sing to you a new song of thanks for our freedom and the redemption of our souls." Why do we use a double phrase - our freedom and the redemption of our souls - to describe the ge'ulah from Mitzrayim?
Rav Chaim Brisker explained that we are referring to two types of ge'ulah - our freedom from the physical slavery in Mitzrayim, and our redemption from the spiritual subjugation we suffered through our exposure to Egyptian culture. Without each one of these redemptions, we would not have achieved a full ge'ulah. At the conclusion of the Maggid section of the Haggadah we thank Hashem for our complete redemption from the slavery in Mitzrayim, while at the same time we pray for the rebuilding of the Beis HaMikdash in the hope that by reconnecting with Shechinah in the Beis HaMikdash we will once again be able to experience a full spiritual redemption.
Perhaps this is why the building of the Beis HaMikdash is mentioned in the Shiras haYam because the shirah is a song about the redemption of Klal Yisrael. Although the physical redemption of Klal Yisrael from Mitzrayim was achieved with the death of their former Egyptian captors at the Yam Suf (see Rabbenu Bachya, Va'eira 6:6), the spiritual redemption of Klal Yisrael was still incomplete until they built the Mishkan, where the Shechinah could dwell amongst them. Klal Yisrael mentioned the building of a Mikdash in the shirah as an expression of their heartfelt desire to experience a full sense of spiritual redemption through the building of the Mishkan.