"Mid-21st century. The post-atomic horror."
The term post-atomic horror was used by future Earth historians to refer to the global turmoil which resulted after the end of the Third World War in 2053. Because the war was a nuclear exchange, large populations of Humans were bombed out of existence, and the survivors were placed in jeopardy by radioactivity, supply shortages, and the collapse of most of the major governments.
In the mid-2050s, Colonel Phillip Green ordered the euthanasia of hundreds of thousands of radiation sickness-stricken Humans so they wouldn't pass on mutations to future generations. Green outlined his rationale by speaking to a crowd about how they must "reject the impure and cast it out." (ENT: "Demons")
During the 2060s, Zefram Cochrane lived in Bozeman, Montana where he and his team of engineers began developing the warp drive and finally built Earth's first warp ship, the Phoenix. The ship drew the attention of the Vulcan ship T'Plana-Hath passing near Earth. The Vulcan ship landed in Montana, thereby making first contact with Humans, and opening a new era for the whole of mankind leading to increased recovery from the war for parts of the world. (Star Trek: First Contact) This event is generally referred to as the defining moment in Human history, eventually paving the way for a unified world government. (TNG: "Attached"; VOY: "Homestead")
However the 'horror' would still prevail for some years to come. When news of this event reached Vulcan, some Vulcans, including V'Lar, were fascinated by Humanity, but also worried, believing the idea that Humans had deemed themselves ready to join the interstellar community, so soon after the war, seemed premature. (ENT: "Fallen Hero") By 2079, the New United Nations had ceased to exist, one such culture reverted to a state of near-barbarism that followed the credo "[Kill] all the lawyers," and "[Guilty] until proven innocent" and martial law was still in effect in some areas of the world. (TNG: "Encounter at Farpoint") Due to these and other factors, parts of Earth continued to be in – as Captain Jean-Luc Picard put it in 2365 – "chaos" well into the early 22nd century. (TNG: "Up The Long Ladder")
Eventually, motivated by the new interstellar reality beginning with the first contact, by the early 2100s – less than two generations of the post-atomic horror – Humanity was finally able to eliminate most if not all poverty, disease, war and hunger. Along with it a lot of other things disappeared from Humanity, including hopelessness, despair, and cruelty. (TNG: "Time's Arrow, Part II"; Star Trek: First Contact; ENT: "Broken Bow") The post-atomic horror gave way to the stirrings of new attempts at establishing various unified world alliances, including the European Hegemony in 2123. (TNG: "Up The Long Ladder") These alliances were eventually instrumental in the establishment of the United Earth Government in 2150. (TNG: "Attached") By 2151 Earth's last holdouts agreed to join United Earth paving the way later for the United Federation of Planets.
In 2364, Q showed the crew of the USS Enterprise-D a barbaric court of the year 2079, complete with drugged soldiers, a crowd of rag-tag mutants and harsh judges handing down summary executions. (TNG: "Encounter at Farpoint") Q returned Captain Picard to the court seven years later after the Q Continuum again tested Humanity with the threat of complete annihilation from an anti-time eruption. (TNG: "All Good Things...")