My co-workers: "Laws are there to stop people from doing things!"

Me: "Do you speed when you drive?"

Them: "All the time!"

Me (internally): I feel like Phoebe talking to Joey.

Laws exist to *discourage* people from doing things, and, maybe, ideally, to cause people to stop and think before they decide if they want to do those things or not.
@eldritch48 also (still in theory) to establish whether punishment is warranted, or who's at fault when bad things happen.
@oblomov but punishment is still just to try to discourage action..it’s not for the people who actually did the thing, it’s to direct future behavior.
@eldritch48 there's a lot to be said about what punishment is for; arguably in practice it is indeed largely intended to be a deterrent (when not, worse, just for the sadistic satisfaction of whoever inflicts the punishment), but it can also be (again, in theory) intended to be a way to have compensation (at a personal or communal level, depending on what one is being punished for), and/or education.