I agree that people will always act in their own best interest, and this is not likely to be in the best interest of the many. There are some people who will act according to their own moral code, but even morality varies. For the sake of the greater good and in order to reign in those who act without moral, we have laws.
Laws exist, simply put, to ensure the greater good for the greater number of people. This in turn ensures a fairly well organized and safe society. If people were not bound by laws, our society would be full of citizens doing what they most felt like doing (for their own needs and desires.) At the risk of sounding cliche, this would lead to anarchy.
Laws exist to provide protection and safety to the society in which we live. As mentioned above, traffic signals help to protect us as we drive to and from wherever we may be going. There are laws in place to help protect us from violence as well.
Thomas Hobbes offered, in my personal opinion, the best justification for laws. Hobbes' argument was that in a "state of nature," everyone was entitled to anything he could possess, and could keep it as long as he could protect it. Such a situation led to Hobbes' famous "war of all against all" in which, as was pointed out in post #1, life was "nasty, brutish and short." Laws were made to LIMIT our natural rights and thereby protect ourselves from each other. No better example exists than standard traffic signals. Stop signs and red lights are a nuisance for us all; yet we know that if they were non-existent, chaos would result. Thus we limit our right to drive when/where we please knowning that others are also similarly limited.
John Locke, of course, argued from a higher purpose; that governments were created to protect our "natural" rights of life, liberty and property. Although he strikes a high moral tone, I do not think that Locke adequately explains the basic selfishness of human nature, and the need to protect ourselves from ourselves.
Laws exist because people are selfish and greedy and would steal from and kill each other if they could. That, at least, is how most thinkers see the question.
This is the answer given by political philosophers like Locke and Hobbes. They wondered why people live in societies with laws and such. They decided it was because societies without laws were places where people's lives were, in Hobbes' words, "nasty, brutish and short."
According to Locke, laws come about because people want their lives, liberties, and property to be protected. Laws are made to prevent other people from violating those basic human rights.