There are also different individuals.
* Those who have a strong idealistic view of the person they wish to be.
* Those who go to great length of avoiding getting shunned by their community (even being called a thief is a great distress for these).
* Those who calculate risk vs reward.
* Those who's worldview doesn't even include the legal system.
The pure idealists are probably rare, but these are the people who judge themselves more than others, who try to follow a certain codex and a consistent moral system. Now this codex might be completely opposite to the law and they might even fight the law, but their behavior is still consistent at all times due to their internal system. These are also the people who deem the justice system as necessary even when it's wrong. These people might end up as Moral Professors, Religious Leaders or founders of Extremist movements.
For most people, the thought of losing their social group is unthinkable, even when calculating Risk vs Reward there is no "Do Evil Deed X, Earn Cash or Jail", rather it's "Do Evil Deed X, Earn Cash or Lose Friends/Family". For these people even mild punishment (getting pointed at in public) is enough to avoid the deed. These people probably had a very good relationship to their social surroundings in the first place, people caring for them, people they care about.
Then there are those who are too irrational or stupid to see the relation between their own actions and their social resources, completely lacks social resources (have no friends/family to lose), have some disorder do not see the need for social resources or who's experience with other people are so bad that their mind simply say "f-them". These people may probably calculate Risk vs Reward in Potential Punishment vs Potential Material Gain.
Finally there are the group who are so irrational and completely void of reasoning that they do not live in the same universe. They have no relationship at all with the society around them and they do not care for it at all, or their irrational emotions drives push them around. Here we have drug addicts, people with strong disorders, very aggressive people etc.