Criminals wont think about how bad prison is because they don't have enough sense to think about how bad prison can be but if they know that they could die because of their crimes, they might just reconsider.
Sure, death penalty is really efficient at preventing crimes.
Proof is that USA definitely has low crime rates! xD