You assume rehabilitation is always possible or cost-effective. From a utilitarian viewpoint, it might be best to simply rid society of some people forever. I’m not arguing for or against that view, but it’s a possibility. The issue of “free will versus determinism” doesn’t settle the question of capital punishment like you think it does.