The theory of the social contract was disputed a lot during the Age of Enlightenment. The more prominent European philosophers—for example, Hobbes and Locke—credited the contract to a variety of reasons, but the principle remained the same. The social contract means that in order for a society to come together and function, people (usually indirectly) consent to giving up some of their individual rights in exchange for protection.
The idea is simple enough, and it would be hard to argue that the social contract doesn't exist. Presumably, every person has, at one point in their life, thought along two lines: one, how nice it is to have laws that defend them; and two, how they'd like to overstep some of those laws in order to get or do something. For example, we can be thankful that there are police officers patrolling and making sure we are safe, but on the other hand, we'd sometimes like to jaywalk or skip school/work, and so on. (These are fairly harmless examples, of course. The social contract isn't in place to fight against jaywalkers.)
The problems in this system arise from poverty and inability to work. What if you are a reasonably wealthy farmer during a time of famine? Is starvation reason enough for people to come and steal everything you've worked hard for?
In a lawless state, without government or any higher order, people would depend on their own power to solve these issues. There is a reason why no (large enough) society is anarchic. The constant state of paranoia and fear wouldn't let a person relax and wouldn't motivate them to work toward something—because that "something" would just be taken from them by someone stronger. Anarchy can only work in small, close-knit communities that trust each other, but of course, even that is a form of a social contract.
So what the contract basically says is, "your right to swing your arms ends where another man's nose begins." It means that a person is entitled to everything that doesn't directly harm anyone else. That means basic human rights, basic liberties, property, and so on. On a deeper level, the great thinkers eventually decided that in order for a society to operate, the contract needs to be enforced. This is why we have governments, ideally democratically chose—and why national constitutions tend to have a paragraph saying that if people feel the government doesn't work in their favor, that government can and should be overthrown.
Basically, then, the social contract means we surrender some freedoms to gain some rights. By not murdering and stealing, we gain the right to be protected from murderers and thieves.
The greatest thinkers of the Age of Enlightenment didn't all agree on why humans enter the state of a social contract. Thomas Hobbes, for one, had a fairly negative opinion of the human experience. He believed that in the natural state, people are harsh and egotistical. Hobbes didn't think it was a question whether a starving man would steal food. Without the fear of punishment, Hobbes thought, people would be only out for themselves. Therefore, he favored a central authority that all people would have to obey without question, except when it was no longer able to protect them.
John Locke didn't quite agree. First of all, he believed that people have natural rights—to live, to be free, to possess their personal property. Locke didn't think these rights were just agreed upon; he argued that they exist independently of whether they're enforced or not. Secondly, Locke's view of the natural state wasn't as harsh as Hobbes's. He thought people have a moral obligation to each other and that people who harm others are more of an exception than a rule. The majority, Locke thought, would simply be forced to live in fear, which he considered to be the reason why people eventually entered a social contract. Additionally, Locke didn't think it was justified to give the government too much power—he just wanted it to be enough to make sure people's fundamental rights were protected.