Government exists because it is generally preferable to the alternative, anarchy, which is the absence of government. The benefits of organizing society under centralized authority almost always outweigh the costs. According to the philosopher Thomas Hobbes, the life of humans in the state of nature is "nasty, brutish, and short." Because no higher authority exists to impose order, humans, equally vulnerable in nature, are in constant danger of violence from each other. They therefore agree to surrender their precarious natural freedom to governments (in Hobbes theory a Leviathan, or monarch) for security. Government exists to insulate us from the arbitrary violence of nature and protect us from each other.
Jean Jacques Rousseau
An 18th century philosopher, Jean Jacques Rousseau offers an alternative explanation. According to Rousseau, mankind in the state of nature was not miserable as portrayed by Hobbes but happy and free. Over time, however, society and its institutions have corrupted man's better nature. "Man is born free but everywhere he is in chains!" Recognizing that government is with us to stay, however, government can only be legitimate when it reflects the collective opinion, or general will, of the people. Governments should be organized to reflect this general will.
John Locke occupies a middle position on the issue of man's relationship to nature, and does not assume that humans are either inherently hostile to one another or selfless. Focusing on the inalienable rights of individuals to life, liberty, and property (sound familiar?) and the practical benefits of cooperation, Locke's theory of government emphasizes the importance of individualism and property rights. Locke is perhaps the purest expositor of classical liberal thought with its emphasis on political and legal equality, equality of opportunity, and a robust defense of property rights. It is his theory that describes the mytho-historical origins of the American state, one based on the principle of individual rights and limited government.
The Social Contract
All of these philosophers used "the state of nature" as a thought experiment for thinking about political legitimacy and shared the conclusion that governments have their origin in an implied social contract. Citizens agree to surrender absolute freedom and obey laws in exchange for the greater security and prosperity that come from living within an organized society. However, if the government fails to protect the governed, they are free to choose another form of government. This idea is clearly reflected in the Declaration of Independence. Rousseau and Locke also share another important assumption: government can only be legitimate when its authority is derived from the consent of the people. This is the principle of popular sovereignty.
But philosophical accounts can really only be idealized accounts of government's origin. Government has existed since the beginning of human civilization, and probably before, originating in the organization of hunting bands among primitive man. Humans embrace government as an organizing principle, or at least accept it as a necessary evil, because its benefits almost always outweigh its costs. The German polymath Goethe once opined that if he were forced to choose between justice and disorder on the one hand, and injustice and order on the other, he would choose the latter. In the more ominous words of J. Edgar Hoover, the notoriously powerful Director of the FBI, justice is incidental to law and order. Happily, the idea that governments should provide both order and justice has become widespread by the 21st century. And the type of government most commonly viewed as serving these values well is democracy.