One [instance was] in the days of Joshua, as it is said: "they gathered together (yaḥdav) to fight with Joshua [and with Israel with one mouth]" (Joshua 9:2). What is the meaning of "together" (yaḥdav)? That they disputed against the Holy One. And one [was] in the days of Gog and Magog, as it is said: "The kings of the earth set themselves, etc." (Psalms 2:2). And here, as it is said: "And the whole earth was [of one language and of one speech]" (Genesis 11:1) — words of reviling they were uttering against the Holy One, except that the Scriptures did not explain [them]; but our Rabbis explained some of them. What were they saying? "After a thousand years and one day and six hundred and fifty-six years, a flood comes to the world, and the heavens totter, and the upper waters will fall upon us. Rather, come and let us make for ourselves parnosin (the meaning is: pillars), so that if the heavens fall, they will hold them up." Hence, "and of one speech."
Why the Generation of Babel Built Pillars Against Heaven
Midrash Tanchuma Buber, Noach 24:5
אחד בימי יהושע, שנאמר (ויקבצו) [ויתקבצו] יחדו להלחם עם יהושע [ועם ישראל פה אחד] (יהושע ט ב), מהו יחדו שחלקו על הקב"ה. ואחד בימי גוג ומגוג, שנאמר יתיצבו מלכי ארץ וגו' (תהלים ב ב). וכאן, שנאמר ויהי כל הארץ [שפה אחת ודברים אחדים], דברים של חרופים היו מוציאין על הקב"ה אלא שלא פרשו הכתובים, אלא רבותינו פרשו מקצתן, מה היו אומרים, אחר אלף שנים ויום אחד ושש מאות וחמשים ושש שנים מבול בא לעולם, והשמים מתמוטטין, והמים העליונים יפלו עלינו, אלא באו ונעשה לנו פרנוסין, (פי' עמודים), שאם יפלו השמים יהיו מעמידין בהם, הוי ודברים אחדים.