Why do we sing the song "Echad Mi Yodeya" at the seder?
R' Yedidiah Tiah Weil (1700s, Prague), in his Hagada commentary Marbeh Lisaper (now available online in English translation by R' Mark Greenspan, in the Sefaria Haggadah), says that the enumerated items in "Echad - Mi Yodeya" allude to the favors that God did for us that are listed in "Dayeinu". Here's a brief synopsis of his explanations:
“One is our God who is in heaven and on earth,” as He demonstrated by taking us out of Egypt and executing judgements against the Egyptians.
"Two are the tablets of the covenant," which represent God's executing judgement against the Egyptian gods, since the tablets contain commandments against worshiping other gods and against adultery.
"Three are the patriarchs," in whose merit as spiritual first-born in their respective families, God slew the Egyptians' first-born.
"Four are the matriarchs," in whose merit God promised four stages of redemption, culminating with giving us the Egyptians' possessions.
"Five are the books of the Torah," whose later acceptance by the Jewish people provided the merit for God's five-fold miracles when He split the sea.
"Six are the sections of the Mishna" - the Oral Torah, which was symbolized by the 600,000-strong Jewish people crossing on dry land through the sea: The Oral Torah is required to traverse the sea of the Written Torah on firm footing.
"Seven are the days of the week," the week following the Exodus, in which we atoned for our transgressions while in Egypt, and thus merited to have the Egyptians drowned in the sea on the seventh day.
"Eight are the days before a Brit Mila," in whose merit God provided for our needs in the desert by providing eight clouds: six protecting us on all four sides, top, and bottom; a cloud of glory for direction by day; and a pillar of fire for direction by night.
"Nine are the months of pregnancy," representing the manna: "According to the Midrash, the manna revealed whether a new born child was a nine month baby from the first husband or a seven month birth from the second husband. Manna then was essential for identifying who the parents of a child were."
"Ten are the Decalogue," which are a representative sample of all of the Commandments, just as Shabbat is a representative sample of their reward - the world to come.
"Eleven are the stars in Yosef's dream," which represent eleven powers of purity that will be necessary to achieve the messianic era, and that were achieved by the assembly at Sinai to enable the establishment of the covenant of Torah.
"Twelve are tribes," each of which is associated with one of the months of the year. The Torah was given in the third month via Moshe, who was from the third tribe, Levi.
"Thirteen are the attributes of God," Whose presence came to dwell among us when He gave us the Land of Israel and the Temple, divided into twelve tribal zones plus the Levitical cities.
R' Pinkus suggests an answer to this question in the introduction to his sefer ברכות בחשבון, which is an entire book about this piyyut.
My translation of the first paragraph of his introduction:
The relevance of this piyyut to the night of Pesach is because the night of Pesach is the time of the birth of Am Yisroel and the foundation of the entire world. In the birth of anything, there is first presented a momentary glimpse of the entire structure of the entity, and everything that will grow and develop subsequently is included in that glimpse. Similarly in the night of the seder, we pass through, in a brief way, the essence of all the structures of the world, until the end of all generations, in all their varieties. The seder itself follows this approach, and we find in it exile and redemption, צפון which is a hint to the revelation of hidden matters (מצפונות) which will be revealed in the future... the great Hallel of the Messianic era, until נרצה which is the final conclusion, ישמח ה' במעשיו, in the future in the World to Come. The piyyutim also follow this approach, like chad gadya which tells of all the events of the generations from the exodus from Egypt until the end of days (I believe this is a reference to the Vilna Gaon's explanation of chad gadya - translator's note). So, too, the piyyut of echad mi yodeya passes through all of the pillars of creation.
So the relevance is that this night is connected to the underlying foundations of existence, and this is the subject and meaning of this piyyut. The sefer then goes through each verse and explains how it represents and conveys these fundamental pillars of existence. I attempted to summarize two of them here.
In the times of the ge'onim, Karaites were disputing the authenticity of our traditions. For this reason, the ge'onim arranged to say things such as Rabbi Yishma'el's thirteen rules every day, to say a hataras nedarim at the beginning of the holiest day of the year (Karaites deny that it is even allowed by the Torah to annul vows, disputing the weak exegesis of הוא לא יחל דברו אבל אחרים מוחלים לו), and other such things, in order to instill in the nation the firm belief in G-d's Torah, written and oral.
Along these lines, they established that we should say "Echad Mi Yodeia," in which we say: Our G-d is one, and He doesn't have a son or any other partner in running the world; the only two and three we have are the two tablets and the three patriarchs. He especially emphasizes the connection between the five books of the Torah and the six orders of mishnah.
In conclusion, we say "שלושה עשר מדיא." Rabbi Maimon suggests that these are not G-d's thirteen attributes of mercy as they are normally understood to be, but rather Rabbi Yishma'el's שלוש עשרה מדות שהתורה נדרשת בהן.
The Hagadas "Atteres Yeshuah" has a beautiful explanation of how this song enumerates the merits in which the Jewish people were redeemed from Egypt:
“One is Hashem” – in the merit of the belief in G-d we were redeemed, as it says (Shemos 4, 31): “And the people believed.”
“The two Luchos” – the Jews were taken out of Egypt to receive the Torah, like it says (Shemos 3, 12): "When you take the people out of Egypt, you will worship G-d on this mountain."
“The three Patriarchs” – we were redeemed in the merit of the three forefathers, as it says (Shemos 2, 24): “And God remembered His covenant with Abraham, with Yitzchok, and with Yaakov.” The Midrash (Shemos Rabbah 1:40) writes that the Jews did not deserve to be redeemed, and it was only in the merit of the forefathers that Hashem took us out.
“The four Matriarchs” – the Gemora (Rosh Hashana 11a) writes that it was in the merit of the Patriarchs and Matriarchs we were taken out of Egypt.
“The five books of the Torah” – the merit of Torah, as explained above (regarding the Luchos)
“The six orders of the Mishna” – the Gemora writes (Gitin 60b): "Hashem made a covenant with Israel only for the sake of that which was transmitted orally."
“The seven days of the week” – according to the Midrash (Shemos Rabba 5:21), the Jews were taken out of Egypt because they rested on Shabbos (the seventh day)
“The eight days before the bris” – Pirkey Derebi Elazar (Chapter 29) “In the merit of the blood of circumcision and the blood of the Korbon Pesach, I redeemed you from Egypt.”
“Nine months of gestation” – an illusion to the “Nashim Tzidkaniyus” (rightouse women) in Egypt who defied Pharoah and engaged in pro-creation.
“The ten commandments” – the merit of Torah, as explained above (regarding the Luchos)
“The eleven stars in Yaakovs dream” – the Jews did not change their names while in Egypt.
“The twelve tribes” – the merit of the twelve tribes; that the Jews guarded the sanctity of their families and did not mix with the Egyptians
“The thirteen attributes of mercy” – the future redemption will come in the merit of the Thirteen Divine Attributes of Mercy.
R' Eran Moshe Margaliot (in Pesach Ha'haggadah p.26) writes that a theme of the Hagaddah is the understanding that a person recognizes that all of his wisdom is not due to his own accomplishment, but rather is from Hashem. Therefore, even a wise person must retell the story each year. This is why we conclude with Echad Mi Yodeya - we are announcing that "mi yodeya" - that someone knows something - is granted from "Echad Elokeinu" - the One G-d.
Another answer given by various Chassidish rebbes, though I have yet to find it in print, is that Echad mi Yodeah is nothing more nor less than a drinking song. It's late at night, you've had four cups of wine (probably larger than a chazon ish shiur). In that state people tend to sing loudly and off-key about whatever is on their minds and -- so the chassidish teaching goes -- what is on a Jew's mind other than God. I doubt this was the original intention of the composer, but it's an interesting perspective.
The recently published "Jewish Wisdom in the Numbers" by Osher Chaim Levene with Rabbi Yehoshua Hartman (Artscroll/Mesorah, 2013) addresses this very question on page 24. It says, in part, "(This) deceptively simple folk-song is not a playful game. It actually points to the great significance invested into numbers when they are framed within a Torah setting." Each verse has a meaningful link to a Jewish concept such as One is Hashem, three are the patriarchs, etc. I have only started to read the book. Perhaps when I finish, I'll expand on the topic. Be forewarned though, I'm a slow reader so it take until next Pesach!
As far as I can tell so far, there is no further explanation as to why this song is sung during the Seder. Perhaps---and this is purely a guess--- the structure of the song: who knows One (Hashem)...I know One, alludes to the underlying mysticism that was understood by Binei Israel after the exodus from Mitzraim and the revelation at Mt. Sinai where, it has been said, even the simplest Jew attained a high level of hidden, deep knowledge of Hashem.