Thank you my dear friend for this very good question! It might be easier to understand this verse if we see it in the context of the chapter. Let’s look at verses 14-16 using the J. N. Darby translation: “For when those of the nations, which have no law, practice by nature the things of the law, these, having no law, are a law to themselves; who shew the work of the law written in their hearts, their conscience also bearing witness, and their thoughts accusing or else excusing themselves between themselves;) in the day when God shall judge the secrets of men, according to my glad tidings, by Jesus Christ.”

Now, as to the “law written in their hearts”, I do not believe that the Scripture is telling us that these Gentiles actually have God’s law “written in their hearts per se,” however they more or less can demonstrate the spirit, or as the Bible puts it, the “works of the law,” being guided by their own consciences. F. B. Hole, in chapter 2 of his book on Romans, said, “Go where you will, you find that men, even the most degraded, have a certain amount of natural light or instinct as to things that are right or wrong. Also, they have a conscience, and thoughts which either accuse or excuse. Hence there is a ground of judgment against them apart from the law.”

You see, God’s law teaches men not to murder, not to covet, not to commit adultery, etc. The Jews have the Law to tell them what sin is, and the Gentiles have a sense of right and wrong, so both are accountable and without excuse when they sin. Thus, the Jews have the Law but cannot keep it, and the Gentiles, at least the more refined Gentiles, seem to have an innate sense of right and wrong (thus showing the works of the Law written in their hearts), and for that reason, both are accountable to God for their works. This is the thrust of the verses you have asked about. The bottom line is that no one is justified by their works, and so, the Jews have no reason to feel superior to the Gentiles merely because as God’s chosen people, they have and try to keep the Law.

To summarize, in verse 15, the Gentiles, who do not have the law, though many are educated and civilized, seem to act in accordance with God’s law (at least in some respects). and so, they demonstrate (or show) the “work of the law” by their actions as governed by conscience, or in other words “written in their hearts.” Yet despite this, they are not justified by their works before God. While the Jews have the Law, they cannot and do not keep it, so they have no right to judge the Gentiles on this ground, because they are really in the same boat, unable to please God by the law which they do have.  they cannot count on their lineage or their good works for salvation.

Now, what does Paul mean in Romans 2:16 by his use of the phrase “in the day when God shall judge the secrets of men, according to my glad tidings, by Jesus Christ.” Well, God’s judgment of all unrighteousness is surely coming upon this world “…in the day when God shall judge the secrets of men…” (see also 2 Peter 3:7,10; Revelation 20:11-13; and Acts 17:31). And how does any man, be he Jew or Gentile, escape this judgment? Well, it is not by keeping the law, because neither Jew nor Gentile is able to do this perfectly (James 2:10). In verses 16-18 of Romans 1, Paul introduces the importance of his “glad tidings,” in other words the Gospel of Jesus Christ. We read in Romans 1:16 the way of salvation…not by works, but by faith in the finished work of Christ Jesus on the cross: “…I am not ashamed of the glad tidings; for it is God’s power to salvation, to every one that believes, both to Jew first and to Greek…”. We all have sinned (Romans 3:23), and we all need a Savior; and Christ Jesus is that Savior (Acts 4:12; Romans 10:9.)  And, we receive forgiveness and the gift of life through faith in Christ Jesus (John 1:12; Romans 6:23; Ephesians 2:8,9; Titus 3:5).  (SF)  (558.5)