The Social Contract Theory is a theory that attempts to explain the origin of government. It states that early tribes decided on a set of rules that would ensure group survival (thou shalt not kill, etc.). To put it in laymen's terms, people decided to give up certains rights for the good of all.
I however, interpret this slightly differently. The good of all isn't what was on the caveman's mind, rather his own survival. If everyone isn't allowed to murder, then no one is going to murder me. The side effect is that I'm not allowed to murder either. Oh well.
Treat other people the way you want to be treated arrises. Because there are no privileged people exempt from the law, anything you decide other people can't do, you can't do either. This path is evident, as almost every culture and primitive tribe has laws of some sort against killing his fellow men. There are exceptions of course (There's an exception to every rule, except the rule of exceptions).
If this is all true, where's the problem? Everyone is only going to get along perfectly as long as it's a unanimous vote. The larger a population gets, the lower the chances of this happening are. This causes conflict and law breaking. Especially when people are forced to conform to laws that were created before they were born and/or had a say in things.
The only way that these conficting ideologies and both Social Contract Theory and Treat people the way you want to be treated can survive (and have survived) is through reasoning that can be explained in the following quote:
"One treats others with courtesy not because they are gentlemen or gentlewomen, but because you are."