Romans 2:12-16
I would like to explain the following scripture, because there are some who don't quite understand it.
Romans 2
12 All who sin apart from the law will also perish apart from the law, and all who sin under the law will be judged by the law.
13 For it is not those who hear the law who are righteous in God's sight, but it is those who obey the law who will be declared righteous.
14 (Indeed, when Gentiles, who do not have the law, do by nature things required by the law, they are a law for themselves, even though they do not have the law,
15 since they show that the requirements of the law are written on their hearts, their consciences also bearing witness, and their thoughts now accusing, now even defending them.)
16 This will take place on the day when God will judge men's secrets through Jesus Christ, as my gospel declares.
The law is spiritual (Romans 7:14). This means that there are spiritual beings associated with the law, who ensure people act according to it. But the law is also the way God wants people to act, which means that the spiritual beings associated with the law, ensure that people act according to the way God wants them to. That is what the following scriptures mean.
Romans 8
9 You, however, are controlled not by the sinful nature but by the Spirit, if the Spirit of God lives in you. And if anyone does not have the Spirit of Christ, he does not belong to Christ.
Philippians 2
13 for it is God who works in you to will and to act according to his good purpose
Therefore the law is simply the way God wants people to act, and its spiritual nature is indicative of the spirits who ensure and cause people to act that way.
The law also refers to a reflection of God's spiritual law in written form. It is important to note that the Bible uses the above 2 definitions for the law, and people should be careful about this when they read the Bible.
Romans 2:12 therefore points out that all who sin, or do not act in accordance with God's law, while not having possession of God's written law, will be punished without it. And those who sin while having God's written law, will be judged by it, and will be punished under it. Romans 2:13 goes on to note that it is not those who know about God's written law who will be declared righteous: rather it is those who obey it – via the spiritual beings who enter them and ensure that they do so, when they have faith.
Romans 2:14-16 indicates that when Gentiles or people who do not have the written law, by nature perform the law, they prove they are one with the spiritual law - meaning that they have God's lawful spirits within them who ensure that they act the way God wants them to. These individuals prove the above is so through their desires which are consistent with God's law, which their consciences bear witness to, while their thoughts accuse and defend them. (The latter part of the previous sentence will take place when they are judged by God.)
It is important to note that all of a righteous man's works (both good and bad) will be tested when he is judged. This is where his conscience and thoughts will bear witness to his happily following the law, but also to his performing deeds under the power of the flesh (Romans 7:25).
1 Corinthians 3
12 If any man builds on this foundation using gold, silver, costly stones, wood, hay or straw,
13 his work will be shown for what it is, because the Day will bring it to light. It will be revealed with fire, and the fire will test the quality of each man's work.
14 If what he has built survives, he will receive his reward.
15 If it is burned up, he will suffer loss; he himself will be saved, but only as one escaping through the flames.
Therefore Romans 2:14-16 indicates that when people who do not have the written law, naturally perform the (spiritual) law; they prove they are one with the (spiritual) law. Also, at the time of their judgments, their consciences will bear witness of their desires to abide by God’s law, while their thoughts will accuse and defend them over their actions here on earth.
I hope the above helps clarify Romans 2:12-16. The passage is essentially about following the law spiritually (which can only be done by having faith correctly) vs. attempting to redeem oneself through the direct pursuit of the written law – which is impossible to do.