Genesis 10 follows the Noah story, giving the genealogies of his son’s Shem, Ham, and Japheth. This section is often called the table of nations as it describes the origins of the major tribes and nations of the earth. Its primary importance is the historical insight it gives on what nations the Ancient Israelites knew existed.
This is followed by the Tower of Babel tale in Genesis 11. In this story, everyone on earth migrates from the east. They all speak the same language. They decide to settle in the valley of Shinar and build a gigantic tower for the purpose of celebrating their own glory (“to make a name for ourselves”). God notices the tower and becomes worried about humanity’s behavior. “If, as one people with one language for all, this is how they have begun to act, then nothing that they may propose to do will be out of their reach. . . .” So God causes everyone to have a different language, making it difficult to communicate, and scatters them across the face of the earth.
On the surface, this is an etiological myth that explains the origins of different languages. Since these cultures didn’t have the scientific method, or more particularly in this case the study of linguistics, they used stories like this to explain important natural and cultural phenomena. God created different languages to stifle humanity’s ambition and vanity.
The story also has a fairly straight-forward moral: Despite being created in the image of God (with similar creative capacity), humans shouldn’t try to be like God and abuse these abilities. This theme conforms with ideas found in previous stories: all of humanity is related and a single family (so why shouldn’t they work together and speak the same language), humanity and God are constantly testing each other and the boundaries of their relationship (which is the main theme/issue running throughout Genesis), and particularly this is another warning against humans trying to be like God (begun in Genesis 3 and revisited here in the tower episode).
Sometimes it is said that Genesis 11 contradicts Genesis 10:5, 10:20, 10:31, which implies that humanity already had different languages. The mistake here seems to be to assume that the narrative follows a perfect chronological order (i. e. we have the events of the genealogy in Genesis 10, then the events of Genesis 11, the Tower of Babel, happens). However, another possibility is that we aren’t meant to read the two narratives as occurring in chronological order from each other. Instead, we have a genealogy that covers a long span of time whose purpose is to document how Shem’s, Ham’s, and Japheth’s offspring became the later nations that occupy the world and the Tower of Babel episode is revisiting an earlier period within this same genealogy in which the differences in languages arose. In other words, the Tower of Babel events occurs before 10:5, 10:20, 10:31 and is a story explaining why different tribes have different languages. So there isn’t really a contradiction. The reason the redactor doesn’t interrupt the genealogy with the story is to keep the integrity of the genealogy as a single literary unit. In other words, they are more interested in literary integrity and literary function than in maintaining perfect temporality.
At the end of Genesis 11, there is another genealogy. We revisit Shem’s line. Placing this list at the end for a second time has two primary literary functions. First, as I already noted, it tells us that the Babel narrative isn’t necessarily meant to be read as chronologically happening after the first lists of genealogies in Genesis 10. After all, if we were meant to read these in perfect chronological order, why would the redactor present a list that he already gave us and supposedly happened before the events of the Tower of Babel? Second, since the specific genealogy at the end of Genesis 11 presents us with the line down to Abram (the next major patriarchal figure), it acts as a transition to the next major character and story line in the Genesis narrative.