This is a very common question and most people give Romans 1:20 as the answer and leave it at that. But this is not enough.
Romans 1:20 20For since the creation of the world God’s invisible qualities—his eternal power and divine nature—have been clearly seen, being understood from what has been made, so that men are without excuse.
Yikes! That’s not enough information would you agree? I mean how can you know about God and Jesus, and their plan of salvation, our need for repentance etc. from looking at trees and nature? At best, we can know that there is a Creator because man did not create the natural beauty and wonders of the world. Even a genius could not connect a bunch of trees with Jesus and the plan of salvation. It would hardly seem fair that they would be damned because they couldn’t glean the gospel message from His creation.
Romans gives a partial answer but there’s more…
Romans 10: 14-17
14How, then, can they call on the one they have not believed in? And how can they believe in the one of whom they have not heard? And how can they hear
without someone preaching to them? 15And how can they preach unless they are sent? As it is written, “How beautiful are the feet of those who bring good news!”
16But not all the Israelites accepted the good news. For Isaiah says, “Lord, who has believed our message?” 17Consequently, faith comes from hearing the message, and the message is heard through the word of Christ.
“Faith comes from hearing.” The gospel must be preached in order for people to hear it and so started the great commission. The Lord doesn’t want to leave anything to chance. He wants to give everyone an opportunity to hear the gospel truth and accept it before He judges them. Observing creation itself cannot provide this – we must be told.
And just for good measure….
14And this gospel of the kingdom will be preached in the whole world as a testimony to all nations, and then the end will come.
Jesus will not come UNTIL EVERYONE has heard the gospel. So there won’t be a soul on the planet who will be judged unjustly because they didn’t have access to the gospel. Everyone will have heard it and when that happens, the end (judgment) will come.
So that question has a false assumption that there will be people who have not heard the gospel, but we see from scriptures that this is not true. The Lord loves us, and wants to redeem as many people as He can and He gives everyone a fair chance by NOT coming until they’ve heard it.