How is the law written on our hearts?

Romans 2:14-15: For when Gentiles, who do not have the law, by nature do what the law requires, they are a law to themselves, even though they do not have the law. They show that the work of the law is written on their hearts, while their conscience also bears witness, and their conflicting thoughts accuse or even excuse them. Hebrews 8:10: For this is the covenant that I will make with the house of Israel after those days, declares the Lord: I will put my laws into their minds, and write them on their hearts, and I will be their God, and they shall be my people.

Romans 2:14-15 refers to an inward sense of right and wrong that all people have. What Paul is saying is that Gentiles — those without the law — do at times keep some aspects of the law without realizing it. But that is not enough. The entire human race is commanded to keep the entire law perfectly and completely — which no man can do (cf. 1 Cor. 7:19; Rom. 2:13, 25-26; Gal. 5:3). A failure to do so means eternal condemnation (cf. Rom. 3:23). As James says, "For whoever keeps the whole law but fails in one point has become guilty of all of it" (Jas. 2:10). And please notice that those referred to in Romans 2:14-15 are Gentiles; they are not God’s people and he is not their God (Heb. 8:10).

On the other hand, Hebrews 8:10 (i.e. Jer. 31:33) refers to those who enter covenant with God through faith and with a greater sense of right and wrong than the Gentiles (cf. Rom. 2:14-15). Why? Because they are God’s people and God alone is their God. They are saved and have the Holy Spirit.

The Holy Spirit continuously convicts believers of sin, righteousness and judgment (John 16:7-11). After regeneration through the Spirit, believers should always be looking to Christ and his law to fulfill their duty of sanctification to the glory of God alone (cf. Psa. 119:97; Phil. 2:12). And though believers at times don’t keep the law perfectly (cf. 1 John 8-10), they have an eternal relationship with Christ their Savior. Christ kept the entire law perfectly and completely (Matt. 5:17-18) and applied this to each and every believer’s account (2 Cor. 1:20; Rom. 5:19; 10:4), so that in Christ they are righteous and remain righteous before God.

People cannot depend upon themselves for righteousness; they need Christ. Without Jesus there is no perfect and complete keeping of the law. And without the perfect keeping of the entire law, there is no salvation, so all that remains is enteral separation from God. Jesus says, "Come to me, all who labor and are heavy laden, and I will give you rest. Take my yoke upon you, and learn from me, for I am gentle and lowly in heart, and you will find rest for your souls. For my yoke is easy, and my burden is light" (Matt. 11:28-30). Receiving Christ into your heart means awareness of the law comes with that, but it's perfectly kept by him for you.