One approach to understanding the building of the city and the tower is that the tower was meant to be used for idolatrous practices. Bereshit Rabbah 38:6 explains that the people said "Come let us build a tower at the top of which we will set an idol holding a sword in its hand, which will thus appear to wage war against Him." (This same idea appears explicitly in the piyyut atah konnata and hinted to in the piyyut amitz koah, both of which are recited in the avodah prayer in the repetition of the chazzan’s Shemoneh Esrei on Musaf of Yom Kippur.) This approach is based on the idea that the word shamayim in 11:4 means the heavens, but really this word in all of the Torah just means air. 11:4 then means that the people wanted to build a tower or building high in the air.
Seforno (on 11:4, see Sanhedrin 109a and Haketav Vehakabbalah on 11:4) varies this idea and suggests that when the Torah records that the people wanted to make a name for themselves this meant they wanted to worship idolatry.
Modern archeological might support this approach, as large towers, called ziqqurat, have been found in many ancient Mesopotamian (Bavel, modern day Iraq) cities. Sarna (1970, pp. 63-80) notes that the Torah specifically records that the bricks for building the tower were baked in an oven and bitumen was used for mortar, 11:3, and this was the method for building in Mesopotamia. Also, the idea of making a name, 11:4, could correspond to the ancient practice of inscribing names of kings on bricks and depositing the bricks in the foundations of the ziqqurat. Ziqqurat were a central part of the Mesopotamian religion that it was believed that by going up to the tower the people would contact god.
Sarna argues that the episode is an anti-pagan polemic since it shows G-d's superiority that G-d could easily stop the building of the tower. This episode could then relate to the birth of Avram, which is recorded at the end of the elleh toledot of Shem, 11:26, because prior to the development of a new religion the Torah shows the meaninglessness of the pagan religion of Avram's time.
While this approach seems reasonable, P.J. Harland (1998) doubts this approach since "there is no reference to any image on the tower,… there is no mention made by the people that they intended any improper worship,"… and he claims the word tower, migdal, should be understood as a fortress and not a tower.
N. Leibowitz (1976, pp. 100-108, see also Ramban on 11:2 though he is very cryptic) proposes a second approach that the purpose of building the tower was "to make man forget his insignificance and transientness, to delude him with his greatness and immortality, in short to make for himself a name." The sin was then of hubris that the people thought they could become like G-d. With this idea, the people's dispersal was a punishment to cut them down to size and reduce their pride. N. Leibowitz further writes that "only when there will be an end to man's pride which takes advantage of the wisdom implanted in him by G-d in order to turn himself into a deity and worship the work of his own hands" will people be able to truly worship G-d. One could then suggest that humankind's pride had to be reduced before Avram was to spread his religious message.
I do not like this approach for two reasons. One, as noted by Sarna, "the desire for fame is perfectly human and not in itself reprehensible. Indeed, the granting thereof is part of the divine promise to Avram, 12:2" (see also Cassuto, 1964, p. 243). Two, is there really a need for G-d to intervene to reduce man's pride? Lemekh (4:23,24) and others since him have been proud and G-d did not intervene explicitly in the world to reduce their pride.
According to the above approaches, the dispersal of the people was a punishment, but there are other approaches which understand the dispersal as a beneficial action. One of these approaches is to argue that the sin of building the tower and the city was that the people were setting up an inappropriate political system. S.R. Hirsch (1989, p. 207) writes that the building was "to make something that should serve as a perpetual reminder of the power of the community over the individual." (I wonder if these comments relate to Hirsch's fight to separate from the Reform community in Germany.) Similarly, Yeshayahu Leibowitz (1990, p. 18) writes that the sin of the building of the city and the tower was not the building per se, but "the aim to use these artificial means to ensure a situation of 'one language and one speech' of centralization, which in modern parlance would be known as totalitarianism." Thus, Y. Leibowitz argues that when G-d dispersed the people, G-d was helping the people by giving them back their freedom. This approach could also relate to the birth of Avram since as Avram was going to start a new nation there was need for political freedom. Yet, while this approach is interesting, I doubt the Torah here is trying to teach us political lessons.
Another approach which views the dispersal of mankind in a positive vein is that the dispersal was part of the fulfillment of the blessing to humankind in 1:28 and 9:1 to "fill the world." (Ibn Ezra end of comments on 11:7, Rashbam on 11:4, Radak on 11:5, Bekhor Shor on 11:4, Hizkuni on 11:1, Luzzatto on 11:4 and Cassuto, 1964 p. 243, all follow this approach. See also Hiebert 2007.) The idea here is that the people wanted to build the tower and the city to ensure that everybody would live in one place since the tower was to be a central point that people would return to. Similarly, the idea of making a name was that if people left the city they would remember the city and return to it (Radak on 11:4). Ibn Ezra (on 11:4) notes that according to this approach there is no issue with the height of the tower, as the phrase "until the heavens" was just meant to imply a tall building (see Devarim 1:28).
According to this approach, the problem here was that G-d did not want people to live in one place since humankind was blessed to spread throughout the world (1:28, and 9:1), and hence G-d dispersed the people. The people were not being punished since it was always part of their destiny to spread out all over the world. Furthermore, according to this approach it is not even clear if the people sinned, as Ibn Ezra (on 11:4) points out that maybe they did not know that they were supposed to spread out all over the world.
This "dispersal" approach accords with the text as 11:4 explicitly records that the people said that they were building the city and the tower "lest we be dispersed over the face of all the earth." The same word for dispersed, nafutz, occurs again in 11:8, va-yafatz, which records G-d's dispersal of the people, and in the last sentence of the description of this incident, which summarizes the incident, 11:9, he-fitzam. We see that this was the main issue that the people did not want to disperse since they wanted everybody to live in some large metropolis, and G-d wanted them to disperse.
Yet, why was there a need for G-d to intervene and disperse the people, as human nature will lead people to go out, travel and explore, and eventually after building the tower, people would have left to go to other places. Furthermore, chapter 10 already recorded that the people had dispersed throughout the world, 10:5,32, which seemed to occur without G-d intervening. Thus, the phrase "all the earth" in 11:1 most likely signifies many people in the world were involved in this project to build the city and the tower, but not that literally every person in the world was involved in building the tower since some people had already dispersed from the area.
People will naturally spread out throughout the world, but the episode here shows that this action is part of G-d's will. G-d's dispersal of the people by the Tower of Babel was then one example of the spreading out of people throughout the world as recorded in chapter 10, and hence this episode is part of the elleh toledot section of chapter 10.
Why was it important to show that the spreading out of people throughout the world was G-d's will? The answer relates to the ensuing narrative, which records the genealogy leading up to Avram. G-d was going to establish a covenant with Avram and his descendants (15:18, 17:7), but did that mean that G-d was no longer the G-d of the other nations? No, and this is seen by the episode of the Tower of Babel. The other nations of the world would not be part of the covenant of Avram, but they were still part of the blessing in Bereshit 1:28, that they should fill the world and conquer it. The episode of the Tower of Babel shows that G-d cares about all people in the world as G-d was helping the people of the world to fill and conquer the world, and hence G-d was also their G-d. To highlight this connection between humankind and G-d, the Torah uses anthropomorphic words, that G-d came down to see the building (11:5) and the use of the royal we in 11:7. The message of 11:1-9 is then to show that G-d is involved with the affairs of all of humankind, even if G-d was about to make a covenant with one nation.
Harland, P.J. 1998, Vertical or horizontal: The sin of Babel, Vetus Testamentum, 1998, pp. 515-533.
Hiebert, Theodore, 2007, The tower of Babel and the origins of the world's cultures, Journal of Biblical Literature, 126:1, pp. 29-58.
Hirsch, S. R. (1808-1888), 1989, The Pentateuch, rendered into English by Isaac Levy, second edition, Gateshead: Judaica Press.
Leibowitz, Nehama (1905-1997), 1976, Studies in Bereshit, translated by Aryeh Newman, Jerusalem: The World Zionist Organization.
Leibowitz, Yeshayahu, 1990, Notes and remarks on the weekly parashah, translated by Shmuel Himelstein, Brooklyn: Chemed Books.
Sarna, Nahum (1923-2005), 1970, Understanding Genesis, New York: Schocken Books.