Some people believe this because of the following scripture.
13 for, "Everyone who calls on the name of the Lord will be saved."
14 How, 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?
15 And how can they preach unless they are sent? As it is written, "How beautiful are the feet of those who bring good news!"
16 But not all the Israelites accepted the good news. For Isaiah says, "Lord, who has believed our message?"
17 Consequently, faith comes from hearing the message, and the message is heard through the word of Christ.
It doesn't say anywhere in scripture however that those who have never heard the gospel are condemned. It does say that gospel can save all and that it should be preached to all.
Take the biblical figure, Abraham. He preceded the Law of Moses and of course before the gospel message was commanded to be preached, and yet he had faith. In fact he is our Father in the faith. Also, before the gospel was commanded to be preached, Jesus told a Roman Centurion that he had more faith than the whole of Israel. And what about Elijah and Enoch who both walked with God?
Obvioulsy given these few examples, you can still know God even if you have never heard the gospel. What if you were born in the Amazon Rainforest and had never had the chance to hear the gospel. Well no matter what your circumstances, we can all know God to a degree through our own GOd given conscience. Conscience is made up to 2 Latin words, con & science. 'Con' means with and 'science' means knowledge. We all have a conscience and no-one can escape Gods judgment because of that. I believe that some serve God more through mere conscience than some who know and live the gospel.
The Jews thought that they were the only ones who were saved. But Elijah wasn't a Jew was he. Now the Christians think that they are the only ones who are saved. Rather if we hear the gospel and respond to it with God's will, then we are guaranteed of our salvation, if we hold on to it. We can know that our names are written in the Book of Life. But to those who have not heard, they will be judged not because they didn't hear the gospel, but on their heart, conscience and works. God is merciful and he can save by his grace anyone he chooses. We cannot dictate to God who will be saved. We have to read all his scriptures and find the balance.
Consider the words of Jesus in Matthew 25 31-46.. It clearly shows that Jesus will divide people from the nations based on their treatment of his brothers. Who are his brothers? Even though this scripture may seem to indicate that people are saved by works, ultimately their works are filthy rags, but God saves them through grace, and he divinely chooses not to save the selfish by his grace. This scripture is pointed to the nations not the Church. Please read....
31 "When the Son of Man comes in his glory, and all the angels with him, he will sit on his throne in heavenly glory.
32 All the nations will be gathered before him, and he will separate the people one from another as a shepherd separates the sheep from the goats.
33 He will put the sheep on his right and the goats on his left.
34 "Then the King will say to those on his right, `Come, you who are blessed by my Father; take your inheritance, the kingdom prepared for you since the creation of the world.
35 For I was hungry and you gave me something to eat, I was thirsty and you gave me something to drink, I was a stranger and you invited me in,
36 I needed clothes and you clothed me, I was sick and you looked after me, I was in prison and you came to visit me.'
37 "Then the righteous will answer him, `Lord, when did we see you hungry and feed you, or thirsty and give you something to drink?
38 When did we see you a stranger and invite you in, or needing clothes and clothe you?
39 When did we see you sick or in prison and go to visit you?'
40 "The King will reply, `I tell you the truth, whatever you did for one of the least of these brothers of mine, you did for me.'
41 "Then he will say to those on his left, `Depart from me, you who are cursed, into the eternal fire prepared for the devil and his angels.
42 For I was hungry and you gave me nothing to eat, I was thirsty and you gave me nothing to drink,
43 I was a stranger and you did not invite me in, I needed clothes and you did not clothe me, I was sick and in prison and you did not look after me.'
44 "They also will answer, `Lord, when did we see you hungry or thirsty or a stranger or needing clothes or sick or in prison, and did not help you?'
45 "He will reply, `I tell you the truth, whatever you did not do for one of the least of these, you did not do for me.'
46 "Then they will go away to eternal punishment, but the righteous to eternal life."
Also have a look at Jesus words in Luke 16:19-25
The only true division is righteous and wicked, not Christian and non-Christian or Jew and Gentile. The gospel is the greatest message because it is the power to save unto salvation to all who believe. It has the power to save the worst sinner and it also has the power to condemn those who think they are righteous. It draws a definite line and it gives us the understanding and confidence to where we stand before God. Our conscience on the other hand is very weak and can condemn us, however God is more powerful than our conscience. Our conscience is God's law written in our heart. Those under the law can be saved because the law points us to Christ. It all depends on your heart motives toward Gods law, not you failings. Of course Christ is the fulfillment of the law, but not everyone is privileged to hear the message of fulfillment (the gospel), but the lack of that message doesn't mean that you are necessarily condemned.