There is a story in the Bible, told in 2 Kings 5, that can help us understand this question. The story is that of Captain Naaman, an officer of high rank in the Syrian army. He was not an Israelite, and was not a God-worshiper; but he had the fortune of having acquired a maid-servant, a young girl, brought captive from Israel. This little girl was able to give him hope when the doctors in his country diagnosed him with leprosy.
In those days, leprosy (now often called Hansen's disease), was incurable. Being contagious, and leading to a miserable death, lepers were forced to leave their family and society and dwell alone or with other lepers. So Captain Naaman's condition was very serious. But the little maid who worked in his home gave him hope, telling him that he could find help in Israel at the hands of the prophet in Samaria. She told the captain's wife that the prophet would be able to heal him. This news was then carried by others to Captain Naaman himself. The record implies that the king heard this exchange--perhaps Naaman was in the king's presence when the news reached him--because the king, not wanting to lose his captain, then sent him with a letter to the king of Israel to seek out this healing--along with "ten talents of silver, and six thousand pieces of gold, and ten changes of raiment."
The king of Israel was shocked to receive a Syrian who had come to ask for healing from leprosy. He was not a prophet, and lacked the prophet's faith. "Am I God, to kill and to make alive, that this man doth send unto me to recover a man of his leprosy?" he responded.
But the prophet Elisha heard about this, and sent a message to the king of Israel, saying, "let him come now to me, and he shall know that there is a prophet in Israel."
Naaman went to Elisha. Upon arriving, he was given a message from Elisha's servant--Elisha did not see Naaman himself. The message was to wash in the Jordan River seven times. Naaman, perhaps offended at not seeing the prophet himself, and being told to wash in the muddy waters of the Jordan, would have return straightaway to Syria had his servants not persuaded him to go ahead and try, as it was but a small thing that had been asked of him. Naaman listened to them, and went down to the river and washed himself seven times. The leprosy was healed. He was clean!
With joy he returned to Elisha. Captain Naaman then says: "Behold, now I know that there is no God in all the earth, but in Israel: now therefore, I pray thee, take a blessing of thy servant."
The captain then offered his gifts, but Elisha would not accept them. The prophet wanted him to know that it was not Elisha the Prophet who had healed him, but the God of Heaven. The captain then says something quite interesting, to which Elisha makes no argument.
In this thing the LORD pardon thy servant, that when my master goeth
into the house of Rimmon to worship there, and he leaneth on my hand,
and I bow myself in the house of Rimmon: when I bow down myself in the
house of Rimmon, the LORD pardon thy servant in this thing. (2 Kings
5:18, KJV)
Elisha says simply: "Go in peace."
Was this permission for Naaman to bow to the idol in the temple of Rimmon? Perhaps not, but neither does God see fit to prohibit him in this thing.
In 1 Samuel 16:7 God says:
. . . for the LORD seeth not as man seeth; for man looketh on the
outward appearance, but the LORD looketh on the heart. (1 Samuel 16:7,
KJV)
God is not looking so much at what we do as at why we do it. What was in our heart? What motive prompted our action? There are many people in "heathen" lands who have not heard about the true God. But God will look at their hearts to see if they are living according to the good that they know. Are they selfish, or unselfish? Are they kind, honest, and true to principle inasmuch as they have understanding? or are they seeking to cheat others, take advantage, and bend the rules wherever possible? Do they do what they believe to be right, or do they try to excuse themselves and rationalize their wrongs?
There are many who do not know God whom God will save. They have done their honest best. They did not know all of the truth, but the followed all of the truth that they had. However, the more truth we know, the better able we are to choose the path of truth. Christians are more privileged than those who are ignorant of God; and this is why they have the responsibility of sharing their knowledge with those who are less privileged.