Read this chapter and you will see clearly that the death penalty was the punishment for the law breakers.
In chapters 18 and 19 God set His discipline before the children of Israel, they came out of Egypt (a pagan land) and were going to Canaan (a land full of enemies – law breakers).
According to the doings of the land of Egypt, where you dwelt, you shall not do; and according to the doings of the land of Canaan, where I am bringing you, you shall not do; nor shall you walk in their ordinances.
You shall observe My judgments and keep My ordinances, to walk in them: I am the LORD your God. Leviticus 18:3-4
Therefore this chapter 20 was commanded as a Law Enforcement to cleanse and discipline His people from Egypt and to prepare them to enter Canaan without contaminating themselves.
However God did not want to execute the human being, rather He was teaching them the “do’s and don’ts”. To solve the issue of the death penalty in the Old Testament He sent His son. For God did not send His Son into the world to condemn the world, but that the world through Him might be saved. John 3:17
Jesus died on the cross for us, His death sentence was in our place. Now the decision is yours, to obey the word of God or not.
I call heaven and earth as witnesses today against you, that I have set before you life and death, blessing and cursing; therefore choose life, that both you and your descendants may live; Deuteronomy 30:19
May the God of the Bible Bless you