Obviously our laws are meant to prevent what we collectively agree upon as "wrong".
I read this once upon a time. This is something I've been thinking about and come to the conclusion that this rationale does not work. Laws cannot prevent anything. They are first and foremost punishments for acts.
Let's say I live in a place where we want to prevent murder. We agree to pass a law that says murder is wrong. Human nature being what it is (witness my vague handwaving) a murder then occurs. The law did not prevent the murder.
We rethink the law and add a penalty, imprisonment. A murder occurs. The law is ineffective, people say. It needs to be stronger.
We pass a law that sets a penalty of death on murder. A murder occurs. The law has failed again. Where can you go from here?
If I want to buy an apple, it costs 25 cents. If I want to buy a car, it costs $20,000. If I want to gather nuts, it costs me 100 kJoules. If I want to hunt a deer, it costs me 10,000 kJoules. If I want to park without paying the meter, it costs me $50. If I want to kill someone, it costs me 12 years.
Laws only set cost. We cannot govern each other's actual behaviours. The law will not enter the mind to prevent such a thing from happening.
The only way to eliminate "wrong" is to eliminate free will. Some acts are clearly wrong. Flying airplanes into buildings: wrong. I can always choose to do these acts, however. I can also choose not to do so, and I frequently do.
I have to make a decision whether or not it will be worth it (vis a vis the cost of my actions). And even then if I can formulate the situation in another way ("I wish to stop the people who are killing my people. My best bet is to kill as many of them as I can." ), then it is not "wrong" from my point of view. We must never underestimate the ability to rationalize our own actions. This is the fatal flaw in using laws to prevent or deter crime.
My brother took my favourite toy. I asked for it back. He said no. There are no parents. I push him down and take it back. As a third party, we would say this act is wrong. I would argue, no, it was my only recourse. I had no access to an arbiter (parent). [And, of course, I would pay no cost since the only witness is biased. :) ]
Thus, even if I live by what I believe is "right", it is my ability to rationalize and justify my own actions that inhibits me from always doing what society would consider right and proper behaviour. We can always rephrase our behaviour to conform to societal norms.
In the end, deterrence is an effect of the law. The cause of the law is to provide a sense of justice after the fact of a crime.