There will always be a tiny sliver of the population who prove themselves unsuitable/unable/unsafe to live freely with society and that society has to deal with them somehow.
Whether it’s better to lock them away to suffer an isolated existence for life or sentence them to die is a matter that can be debated I think, as both paths have elements that are more terrible than the other.