Jesus said the greatest commandment was “to love God with all of your heart, soul, and strength” (Matt 22:34-40) In addition, Jesus said, “if you love me you will keep my commandments” (John 14:15). It’s not possible to keep any of the commandments until you do the greatest one first.
You have to love him and others in order to even want to keep his commandments. 1 John 4:7-8 says, that anyone who loves is a child of God and knows God, but anyone who does not love does not know God, for God is love. The 2nd greatest commandment is to love your neighbor as yourself and that includes your enemies (Matt 5:44-48). This means loving people enough to avoid harming them and also loving them enough to apologize when you fail to love them in the first place.
Fear of repercussion can only do so much to prevent people from sinning. Fear only makes them hide it and lie about it. In the old covenant, the death penalty functioned as a deterrent to prevent most people from sinning, but people still overcame their fear and did it anyway hoping they were clever enough to avoid getting caught. Only the people that truly loved God were the ones that resisted sin or repented immediately afterward rather than continuing in secret, David is an example of such a person. Love can change a person’s intentions and stop them from doing harm in the first place, and cause them to apologize when they do make a mistake. When you love someone you won’t want to harm or disappoint them. In other words, love is a greater motivator to resist sin and do what is right than fear.
John said in 1 John 4:18, “there is no fear in love because perfect love expels all fear. If we are afraid, it is for fear of punishment, and this shows that we have not fully experienced his perfect love.” John got this revelation because in the new covenant, believers have access to the holy spirit and no longer need fear as a primary motivator to follow God. It’s the holy spirit that was promised to circumcise our hearts (Deut 30:6, Jer 4:4, Ez 36:25-27, Joel 2:28-32, Acts 2:16-21, Rom 2:29, and Col 2:11) and give us the power to overcome sin nature so that we could accomplish the task of keeping God’s commands. A man will have more power to resist adultery if he is resisting because he loves his wife, rather than simply because he fears getting caught.
Examples: When Potiphar’s wife seduced Joseph in Genesis 39:6-10, his response was, “how could I do this great wickedness against God?” Joseph loved God so much that he refused to sin against him by giving in to the advances of his master’s wife. In Daniel ch. 3, the three Hebrew boys were willing to get thrown into a furnace because they loved God so much they would rather die than sin against him by worshiping the government’s idol.