Is it possible for anyone to go to heaven just by their good works?
It may be logically possible that if someone never sinned even once then they can go to heaven.
(DG) If there was one who genuinely did good at all times, they could merit eternal life of their own accord - but there is none, because all, in some way or another are or have been or will be self-seeking and do not obey the truth, but obey unrighteousness.
(JC) If they have done total good, giving God all glory in everything they’ve said, done, or thought, they’ll make it to heaven. In other words, to the moralist, to the person who is super pious, Paul is saying, “If you are really good, you’ll make it in. If all of your days you’ve glorified God with all of your heart, and have lived honorably in everything you do, say, and think, you’ll inherit eternal life.”
There may be some morally better than others as described in Romans 2:1-5 but even their righteousness are filthy in the sight of God i.e. our righteousness never meets the God's righteous standards.
Isaiah 64:6 - But we are all like an unclean thing, And all our righteousnesses are like filthy rags; We all fade as a leaf, And our iniquities, like the wind, Have taken us away.
Practically it is impossible to live a perfect life as God expected/standards because if we sinned once in our life time then we are guilty of all and we will not be justified, saved or allowed to enter into heaven. Because all are judged based on God's standard as given in Romans 2:7 and James 2:10 not based on human standard:
Rom 2:7 - eternal life to those who by patient continuance in doing good seek for glory, honor, and immortality;
James 2:10 - For whoever shall keep the whole law, and yet stumble in one point, he is guilty of all.
Paul also making this clear that all humanity (immoral people in Romans 1:18-32 and self righteous people in Romans 2:1-5) are guilty of their sins:
Romans 1:20,21,32 - 20 For since the creation of the world His invisible attributes are clearly seen, being understood by the things that are made, even His eternal power and Godhead, so that they are without excuse, 21 because, although they knew God, they did not glorify Him as God, nor were thankful, but became futile in their thoughts, and their foolish hearts were darkened. ...
32 who, knowing the righteous judgment of God, that those who practice such things are deserving of death, not only do the same but also approve of those who practice them.
Rom 2:3-5 - 3 And do you think this, O man, you who judge those practicing such things, and doing the same, that you will escape the judgment of God? 4 Or do you despise the riches of His goodness, forbearance, and longsuffering, not knowing that the goodness of God leads you to repentance? 5 But in accordance with your hardness and your impenitent heart you are treasuring up for yourself wrath in the day of wrath and revelation of the righteous judgment of God,
Romans 3:10-12 - 10 As it is written: "There is none righteous, no, not one; 11 There is none who understands; There is none who seeks after God. 12 They have all turned aside; They have together become unprofitable; There is none who does good, no, not one."
Romans 3:23 - for all have sinned and fall short of the glory of God,
Therefore no one can obey the law perfectly as God expect in Romans 2:7.
(JC) But guess what. Only one Man has ever lived like that—and it was His blood that was shed for the rest of us.
Heb 4:15 - For we do not have a High Priest who cannot sympathize with our weaknesses, but was in all points tempted as we are, yet without sin.
For further details read What are all we needed to enter into heaven?
(DG) This is God’s answer to the one who says, “What about the Pygmy in Africa who has never heard the gospel?” God will judge that Pygmy by what he has heard, and how he has lived by it. Of course, this means that the Pygmy will be guilty before God, because no one has perfectly lived by their conscience, or perfectly responded to what we can know of God through creation.
The problem of the “innocent native” is that we can’t find an innocent native anywhere.
“What about the Pygmy in Africa who hasn’t heard the gospel?” is a good question, but there are two far more important questions:
What about you who hear the gospel, but reject it? What excuse is there for you?
What about you, who are commanded to take the gospel to that Pygmy in Africa (Matthew 28:19), but refuse to do it?
What is the problem "if you say/think that there were some live in remote area who never get a chance to hear about our God Jehovah or our Lord Jesus Christ then God will judge them differently with some concession and allow them to heaven if they live a perfect righteous life without having faith in God/Jesus Christ"?
If God judges differently based on their location, circumstance, ... then you are saying that God will show partiality to them on the judgment day. In this case you are denying that God is Righteous and God is impartial:
Rom 2:11 - For there is no partiality with God.
Rom 9:14 - What shall we say then? Is there unrighteousness with God? Certainly not!
For more details read How is God reaching out all of us? topic.
What is the problem "if you say/think that we can live a perfect righteous life and enter in to heaven"? Or
What is the problem "if you say/think that on judgment day God will allow all people to enter in to heaven who lived a perfect righteous life but without having faith in God/Jesus Christ"? Or
What is the problem "if you say/think that there were some in remote area before Jesus Christ 1st coming who carefully lived such a righteous life will pass God's judgment and enter into heaven"?
If it is possible for someone to enter into heaven by perfect righteous living before Jesus 1st coming then it is also possible that after Jesus Christ even now anyone who live such a perfect righteous life can enter into heaven. If anyone can live such a perfect life then they are sinless. In this case you are saying that ...
Jesus is not the only sinless person exist in this world but there are many lived/living/live a righteous sinless life and enter into heave. Here you are denying the absolute truth about Jesus Christ and ourself:
Romans 3:23 - for all have sinned and fall short of the glory of God,
Gal 2:21 - I do not set aside the grace of God; for if righteousness comes through the law, then Christ died in vain."
Jesus is not the only way to the heaven. Here you are denying the Jesus Christ saying:
John 14:6 - Jesus said to him, "I am the way, the truth, and the life. No one comes to the Father except through Me.
Since no one can enter into heaven by their right living so God come up with New Covenant through His Son Jesus Christ who is the only sinless person ever lived in this earth:
Heb 8:7,8 - 7 For if that first covenant had been faultless, then no place would have been sought for a second. 8 Because finding fault with them, He says: "Behold, the days are coming, says the Lord, when I will make a new covenant with the house of Israel and with the house of Judah-- 9 not according to the covenant that I made with their fathers in the day when I took them by the hand to lead them out of the land of Egypt; because they did not continue in My covenant, and I disregarded them, says the Lord.
For this reason Jesus judge using the Gospel in Romans 2:16.
Note: Romans 1:18 - 3:20 covers this in more detail.