I was not saying that the justice system should avoid pain to the guilty but rather work on a principle of least harm. If a person has slain several people, and it is likely he will do so again, society might be better off with the person locked away. A life imprisonment can be, if not canceled, then terminated and amended financially.
It of course depends on the nature of the prison. I would claim it could be just like a regular apartment - except you can't leave. There is no reason for it to be doomy , gloomy and grimy if the raison detre is to protect the society from the person locked away.
I think norway's treatment of prisoners is great example of how to do this as sensibly as possible https://en.wikipedia.org/wiki/Life_imprisonment_in_Norway