I think most people who commit crimes do not believe they will be caught. Most data shows sentencing shows no deterrence. Alternatively sometimes fines do more to deter than other penalties. A theory I remember from a college class on the topic were that sentences are so unevenly applied that many people reason that they won't actually get the max sentence.
Most people who commit crimes aren't caught. Around 38% of murders remain unsolved.
Most of those who are caught aren't brought to trial. For obvious reasons, prosecutors strongly prefer cases supported by very strong evidence.
The corollary is there are a lot of murderers walking around unremarked and free - either caught and released for lack of evidence, or not caught at all.
So it's unlikely the death penalty has much a deterrent effect. There would be a much stronger deterrent effect if there was some magic way to increase the catch rate which didn't also intrude on privacy or civil liberties.