There are four letters to God's name, four cardinal directions and there are four Matriarchs. On Pesach, four is everywhere:
the Four Questions, the Four Sons, and four cups of wine. With four names of the chag - Hamatzot, Pesach, Zman Cherutenu and HaAviv, you get four groups of four.
Four is also a common factor in the esoteric Jewish tradition: four angels surround the Throne of Glory in Ezekiel's vision, there are four kingdoms of the book of Daniel, and the famous four Sages who go for a stroll in the Pardes.
By Mishnaic times (c. 200 CE) the practice of four cups in the seder is codified, so the actual practice is much older. Where does it come from?
Note that in the Babylonian Talmud the number four does not get a very good reputation, and therefore a longish discussion on why four cups appears.
That idea that four is a dangerous number appears to be absent in the Jerusalem Talmud, which prefers to wonder simply where do we get four; and actually comes up with a few answers:
The four positions relayed in the Jerusalem Talmud provide four different ways to conceive the Exodus and its effect on us, today, in our sedarim. Rav Yochanan and Rav Yehoshua ben Levi conceive the four cups as a means to see ourselves and our future by focusing back on our history – the former to our start as a nation, and the latter to the start of our descent into Egypt. Yet Rav Yochanan focuses on the actual redemption, while Rav Yehoshua ben Levi offers a way to see its beginnings even in the darkness of Yosef’s enslavement in Egypt. Rav Levi and the Rabbis conceive the four cups as a means to bring our redemption from Egypt forward into our present and future consciousness – the former to our current time and the latter to the end of days. How to frame the arc of our collective history is what pouring the cups actually asks.
The one problem with Rav Yochanan's/R. Benniah is that a fifth expression is not included - which is part of what we talk about in the seder, entering the land.
R. Daniel Landes, quoting R. Yitzchak Ze'ev Halevi Soloveitchik in My People's Passover Haggadah Vol 1 p. 136
Each of the four cups is an organizing anchor for a different section of the Seder:
first cup: the Kiddush, declaring the holiness of the day (KADESH)
second cup: telling the story (MAGID)
third cup: the Grace After Meals, Birkat ha Mazon (BARECH)
fourth cup: singing the Hallel Psalms (HALLEL)