My own idea about the story of the Tower of Babel is that it was the response of the exiled Israelites to their first experience of the great city of Babylon; I emphasise that this is only a piece of speculation.
At the time of Nebuchadnezzar Babylon was the largest city in the world, a sort of Baby London, with a population of about half a million. This was probably more than ten times the total population of Judea and at least a hundred time the population of Jerusalem. To an Israelite such a city would have been beyond their imagination; the huge buildings, the great ziggurats, like artificial mountains, that seemed to reach almost to the sky, and wealth beyond the dreams of Solomon in all his glory. To the exiled Jews it would have seemed that these people could do anything and that nothing that they imagined would be beyond their power (Genesis 11:6).
However, as they learnt more, the Jews would have found out that, like all large towns and cities, Babylon contained different communities, different ethnic groups with different languages, with their inevitable disagreements and conflicts. Perhaps the Jews thought that God had divided the people of Babylon into different linguistic communities to prevent them from getting above themselves (particularly in building towers) and to ensure that they would not be able to do anything that they wished to. If so, the myth of the tower of Babel was an attempt to understand how a cosmopolitan city, a single unit that nonetheless consisted of diverse ethnic and linguistic groups, had come into existence.