One of the Thirteen Principles of Faith of the Rambam is that we clearly believe in reward and punishment. We are to understand that our good deeds are rewarded and we are liable for our sins.
Hashem is the true judge and He is the One who decides how to carry this out. Ultimately, there is absolute justice.
When we learn of certain sins that carry with it the death penalty, it is obvious that these are viewed as very serious violations. However, it is difficult to carry out such punishments. There must be two witnesses and a clear warning before carrying out capital punishment. We need a court of twenty three and a clear majority of thirteen to ten.
What should make an impression on us is the moral outrage that the Torah is expressing when mentioning a death penalty. We must not take these laws lightly and not forget that there is justice in the end.