Punishment is emotional, rehabilitation is practical, but there are no rules without exceptions.
But, let's not forget that prison is also about separation, for example pedophiles - or pedophile child-killers - or worse, where the issue, while it may be revenge-driven, should mainly be about separation from society.
And in this case begs the question: How much do we charge society yearly, to keep these unredeemable offenders alive and healthy?
That said, the VAST majority of inmates, in the VAST majority of prisons, anywhere, have done crimes of much less importance. Even the majority of murders commited are one-time cases (probably not counting notorious crime-holes, but I believe even there statistics are exaggerated, especially for most western nations). It is unlikely that a murder in affection will repeat itself. Someone who kills someone over debts or jealousy or revenge will typically have quite a limited number of such enemies, usually just one, whom they eventually dealt with. Accidental manslaughter is another example - do we REALLY need to punish/rehabilitate/separate someone who weren't even AWARE they were commiting an offense? Most countries will show leniancy towards such cases, but even then, "symbolic" punishments are given - like.. 1 year in prison, or something. What for!? What will that achieve!?
I can't offer solutions that will please everybody on this matter, but todays prison system is flawed and medieval in nature. To recap - prison should mainly be about separating truly dangerous repeat-offenders from society. Someone who commited a crime in desperation or affection do not count as "truly dangerous" in that sense, imho, and even less do victim-less crimes.
"Hey now - there is NO such thing as a victim-less crime!" of course there is.
"Hey now! Even your pot-smoking causes victims in.. eh... idunno... brown-skinned countries! I suppose." no. They cause paychecks.