I think part of the reason for the harsh punishment was hopefully to return the person to the straight and narrow path. Maybe even to save their soul.
Harsh punishment can prevent a lot of wrongdoing too.