they aren't locked up to protect society, they are locked up to protect the social contract, a concept that dates back to Hammurabi. it is the human condition to have rules and for people to break them, you won't cure that until every last human is dead... so instead you have a social contract: an idea, that breaking the rules will get you punished. it won't prevent people from breaking the rules, nothing can prevent that, but it can make people realize there is a cost they will have to pay for breaking the rules. if they get desperate or crazy enough, they won't care and will break them anyway. no way to stop a crazy/desperate person, Socrates figured that out 2000+ years ago, and it hasn't changed since.