According to a biblical account found in the book of Genesis, people once spoke the same language. Then, because those people banded together to build a tower in Babylon that glorified their own achievements, rather than those of their deity, God punished them. He ensured that mankind spoke different languages so that they'd never be able to work together to dishonor God again.
Was there once just a single language that all people could understand? Linguists don't know; there's just not enough information about the origins of language, and there are only theories about how our early ancestors formed their first words and sentences. Did early people imitate sounds they heard in the environment? Did they babble until certain sounds took on meaning? We'll probably never know, though linguists still study babies' brains to determine if language or grammar comes hardwired in our heads.
One prominent theory about the development of the first languages relates to tools and resources. Teaching another person how to use tools requires a certain, agreed-upon vocabulary, as does the process of sharing and protecting resources like food and shelter. Small groups of people living in close quarters would therefore need to develop a way to understand each other, so they came up with a vocabulary and syntax that meant something to them. A group of people across the world from them, though, would probably need an entirely different vocabulary of words, so the languages would have developed differently in isolation. Think of the oft-quoted (but erroneous) example that Eskimos have 100 different words for snow because they have so much of it. While that common statement is wrong, there are cultures that have far more words for rice and camels than, say, English does.
So these small groups of people, living in isolation from one another, agreed on names for their tools and food, and they came up with ways to describe how resources would be divided. But when another group migrated into the area, or came with different resources to trade, the groups had to find a way to merge their different lexicons and communicate. Over time, that's how languages have developed, and as some groups conquered others, that's how some languages died out.
Travel among groups who speak different languages has been difficult over history; now, we live in a world where we can board a plane in New York City and land in China hours later. In a global world, wouldn't there be a benefit to speaking the same language? Some groups have advocated that a universal language be adopted, but it would be difficult to find any group willing to give up their own language if only because so much culture and history becomes embedded within it over time. After all, the English would no sooner give up the language of Shakespeare than the Spanish would forsake the tongue of Cervantes. Attempts to create a universal second language have failed as well, but even if we could agree on a common language, it's unlikely it would resemble itself 100 years from now. After all, thanks to the Internet's influence, language has become a mix of emoticons and abbreviations like LOL. Languages simply evolve too rapidly to ever speak just one.