Headcanon: Before Ba Sing Se was built, the eastern and western tribes of the southern Earth continent were competing with each other over the north.
They unified into two rival confederations that were about to go to war. Each of them amassed a giant fleet of ships that were heading to collide in the bottleneck in the middle of the great lake.
Thousands would’ve died if it weren’t for the Avatar, who erected a massive wall of earth in the middle of the lake while in the Avatar State, blocking the two fleets from engaging one another. Thus creating the Serpent’s Pass.
Under the guidance of the Avatar, the two groups united into one and decided to settle the land that would become Ba Sing Se together.