Humanity has had a long and violent history. During the 20th century they fought their first world war, which was followed by a second in under 25 years. A century later they would fight their third and final world war.
Humans also fought a war against genetically engineered humans called augments during the late-20th century. For centuries after this event the issue of genetic engineering has been a taboo among humans and later the Federation. (TOS: "Space Seed"; DS9: "Doctor Bashir, I Presume")
Following the third world war human society teetered on the edge of complete destruction. Around ten years after the end of the war Zefram Cochrane built the first warp drive and successfully tested it. This attracted the attention of a passing Vulcan starship, which landed and made first contact with the human race. (Star Trek: First Contact)
However, this was not the first time aliens had visited Earth. Over the centuries several species visited the planet, some by accident others by design. Several species transported a number of humans off Earth and populated other planets in the Milky Way with them. (Star Trek: The Original Series; VOY: "The 37's")
Over the next century humanity rebuilt Earth and rid it of war, disease, poverty and hunger. The nation-states of Earth banded together under the banner of United Earth and started to extend humanity's reach to the stars, colonising several planets. They eventually became embroiled in a conflict with the Romulan Star Empire. (TOS: "Balance of Terror") From this conflict came the birth of the United Federation of Planets or which humanity was one of the first members and continued to be one of the most influential members for centuries to come.