There are many different versions of the notion of a social contract. A common description of the social contract is that people give up some of their rights in order to get the benefits of living in civil society. For example, the current version of the Wikipedia article "Social contract" says:
Social contract arguments typically posit that individuals have consented, either explicitly or tacitly, to surrender some of their freedoms and submit to the authority of the ruler or magistrate (or to the decision of a majority), in exchange for protection of their remaining rights.
John Locke's version of social contract theory is striking in saying that the only right people give up in order to enter into civil society and its benefits is the right to punish other people for violating rights. No other rights are given up, only the right be be a vigilante.
Even the right to be a vigilante returns to the individual if the government breaks the social contract by not punishing those who violate rights. (See John Locke: When the Police and Courts Can't or Won't Take Care of Things, People Have the Right to Take the Law Into Their Own Hands.) But the principle that "People Must Not Be Judges in Their Own Cases" means that no one person or group of people who all have the same grievance should make the decision that the government has failed in its job of punishing those who violate their rights. There should be some substantial set of individuals who do not have a direct grievance who also think that the government is failing in its job before anyone takes the law into their own hands again. And the principle that people must not be judges in their own cases means that setting up at least an ad hoc civil society to patch the regular government's failings is better than reverting to anarchy.
To see that according to John Locke we retain all the rights we would have in the state of nature other than the right to punish, consider Sections 88 and 89 of John Locke's 2d Treatise on Government: “Of Civil Government” (in Chapter VII, "Of Political or Civil Society"): they are clearly about the social contract but only mention the right to operationalize the law of nature in detailed legislation, judge according to those laws, and mete out appropriate punishments:
§. 88. And thus the commonwealth comes by a power to set down what punishment shall belong to the several transgressions which they think worthy of it, committed amongst the members of that society, (which is the power of making laws) as well as it has the power to punish any injury done unto any of its members, by any one that is not of it, (which is the power of war and peace;) and all this for the preservation of the property of all the members of that society, as far as it is possible. But though every man who has entered into civil society, and is become a member of any commonwealth, has thereby quitted his power to punish offences, against the law of nature, in prosecution of his own private judgment, yet with the judgment of offences, which he has given up to the legislative in all cases, where he can appeal to the magistrate, he has given a right to the commonwealth to employ his force, for the execution of the judgments of the commonwealth, whenever he shall be called to it; which indeed are his own judgments, they being made by himself, or his representative. And herein we have the original of the legislative and executive power of civil society, which is to judge by standing laws, how far offences are to be punished, when committed within the commonwealth; and also to determine, by occasional judgments founded on the present circumstances of the fact, how far injuries from without are to be vindicated; and in both these to employ all the force of all the members, when there shall be no need.
§. 89. Wherever therefore any number of men are so united into one society, as to quit every one his executive power of the law of nature, and to resign it to the public, there and there only is a political, or civil society. And this is done, wherever any number of men, in the state of nature, enter into society to make one people, one body politic, under one supreme government; or else when any one joins himself too, and incorporates with any government already made; for hereby he authorizes the society, or which is all one, the legislative thereof, to make laws for him, as the public good of the society shall require: to the execution whereof, his own assistance (as to his own decrees) is due. And this puts men out of a state of nature into that of a commonwealth, by setting up a judge on earth, with authority to determine all the controversies, and redress the injuries that may happen to any member of the commonwealth; which judge is the legislative, or magistrates appointed by it. And wherever there are any number of men, however associated, that have no such decisive power to appeal to, there they are still in the state of nature.
On this model, the government is limited in two ways. First, it cannot take away from us any rights we would have in the state of nature, and is given only the right to punish for things that deserve punishment. Second, the government can only punish for things that deserve punishment, and these are the same things that would deserve punishment in the state of nature. That is, while the government can operationalize the law of nature in more detailed legislation, it cannot legislate anything that is not in the law of nature.
How does one tell what is in the law of nature that a government can legitimately turn into detailed legislation? Think of what would be right and just in a frontier community in an area so sparsely settled that there is no sheriff or city council anywhere in sight. (See "Vigilantes in the State of Nature" for more vivid versions of this kind of image.) The justice of any action of the government in a large nation must be argued by those same principles of what is right and just in that frontier community with no functioning government. Established governments should be given some deference in interpreting the law of nature in this sense, but according to John Locke, they have not right to legislate anything contrary to that law of nature.
Michael Huemer looks closely at our intuitions for what someone can legitimately do acting as an enforcer in such a sparsely settled frontier community with no established government in The Problem of Political Authority. My intuitions would allow someone acting as an enforcer to do somewhat more than Michael's intuitions (for example, I think "taxes" in the form of reasonable required contributions for important public goods such as fending off an attack that could get everyone killed), but I think Michael's method is the right one.
I love the idea that what is wrong for an individual in the state of nature cannot suddenly become OK just because the government is doing it. The state of nature is a tough place, so many things might be OK in the state of nature. Almost all of us are familiar with the exigencies of the state of nature because so many action movies derive much of their interest by putting the characters into something that bears the hallmarks of the state of nature. (How many times have you seen in a movie or TV show someone saying "I can't go to the police because ...."? Except in cop and detective shows, it is hard to drive the plot if people just call the police.) But if it isn't right in the state of nature for individuals to enforce, even in an emergency, or in a situation where there is a huge benefit to be gained, it isn't right for the government to do.
For links to other John Locke posts, see these John Locke aggregator posts:
Also, see these other posts referencing Michael Huemer: