Praise be to Allah, the Lord of the Worlds; and may His blessings and peace be upon our Prophet Muhammad and upon all his Family and Companions.
Allah never sends his wrath on any one until He gives evidence to prove him guilty. Allah Says (interpretation of meaning): {…And We never punish until We have sent a Messenger (to give warning).}[17: 15]. The meaning of “giving evidence” against disbelievers here is that the message of Allah reaches them and they get to realize its existence. Ibn Al-Qayyim said in his book Madarij As-Salikeen, 'Evidence of Allah is through sending Messengers, sending Books with them and making that message reach them and having the ability to learn it. At this stage the person is responsible for everything he/she does. His/her ignorance in this case is not an excuse. Everyone, who neglects Allah’s Message and fails to follow what He has ordained Allah and avoid what He has prohibited, is guilty. Allah never punishes a person unless he/she was introduced to the above evidence.'
It is very important to clarify that giving evidence is different according to the cases, times and persons. Ibn Al-Qayyim said, 'Giving evidence against someone is different due to different conditions, times and persons. Giving Allah’s Evidence against man’s rejection of Faith might differ from time to another, or a place or town to other. It is also different from one person to another due to the lack of intellectual ability or, ability to discern or the age (not reached the age of puberty) such as a minor or a mad person, or the one who cannot understand the language of address without a translation. If it is proved that he received the Message of Islam and rejected it, and died as a disbeliever, he would dwell in Hell-fire forever.'
Allah Says (interpretation of meaning): {Verily, those who disbelieve, and die while they are disbelievers, it is they on whom is the Curse of Allâh and of the angels and of mankind, combined. They will abide therein (under the curse in Hell), their punishment will neither be lightened, nor will they be reprieved.}[2:161-162]. He also Says: [And whoever seeks a religion other than Islâm, it will never be accepted of him, and in the Hereafter he will be one of the losers.}[3:85].
As for unbelievers’ good deeds in the life of this world (Dunya) it will not benefit them on the Judgment Day. Unbelief and paganism shall bring their good deeds to naught. Polytheism is absolutely the worst of all injustice. Allah Says (interpretation of meaning): {…Verily! Joining others in worship with Allâh is a great Zûlm (wrong) indeed.}[31:13]. He also Says: {Whereby the heavens are almost torn, and the earth is split asunder, and the mountains fall in ruins, That they ascribe a son (or offspring or children) to the Most Beneficent (Allâh).}[19:90-91].
You have to discern the roguishness and wickedness of the polytheists and Trinitarians. The system of the universe is nearly cleft asunder due to their calumny.
What should their good deeds be in this world while disobeying their Creator and Evolver? What should their good deeds be while distorting the absolute fact concerning the Tawheed of Allah? They have terrible beliefs like trinity and polytheism.
As for the Jews who believe in the Tawheed of Allah, they describe Him as poor, getting tired and being forgetful. “Glory to Him! He is high above all that they say! Excellent and Great (beyond measure)!
Allah Says (interpretation of meaning), in reply to their blasphemy: {And indeed We created the heavens and the earth and all between them in six Days and nothing of fatigue touched Us.}[50:38]. He Says: {Indeed, Allâh has heard the statement of those (Jews) who say: "Truly, Allâh is poor and we are rich!"}[3:181]. He also Says: {The Jews say: "Allâh's Hand is tied up (i.e. He does not give and spend of His Bounty)." Be their hands tied up…}[5:64].
Due to their faithlessness, their good deeds will not be accepted. Allah, the Exalted, Says (interpretation of meaning): {And We shall turn to whatever deeds they (disbelievers, polytheists, sinners, etc.) did, and We shall make such deeds as scattered floating particles of dust.}[25:23]. Ibn Kathir said, 'Allah’s Saying: {And We shall turn to whatever deeds they (disbelievers, polytheists, sinners, etc.) did, and We shall make such deeds as scattered floating particles of dust} means that will take place on the Judgement Day when Allah takes/brings people to account for their good and evil deeds.'
Unbelievers’ good deeds won’t be accepted on the Day of Judgment because they lack devotion and consistency which are fundamental in Islamic Canons. Good deeds are null and void if they are not compatible with the Islamic rulings or if they lack sincerity. Unbelievers’ deeds lack one or both of the two conditions which consequently puts their deeds much farther from being accepted.
Ash-Shawkani says – concerning this verse: {And We shall turn to whatever deeds they (disbelievers, polytheists, sinners, etc.) did, and We shall make such deeds as scattered floating particles of dust.} that the unbelievers were doing good deeds like rendering to the kindred their due rights, relieving the distressed, offering food out of charity and the like. But their disbelief deprived them of Allah’s reward. Allah Says (interpretation of meaning): {The parable of those who disbelieve in their Lord is that their works are as ashes, on which the wind blows furiously…}[14:18]. He also Says: {As for those who disbelieve, their deeds are like a mirage in a desert. The thirsty one thinks it to be water, until he comes up to it, he finds it to be nothing,…}[24:39].
This reward will be in the Hereafter. In this worldly life, Allah rewards the unbeliever for his deed before death; Allah never oppresses anyone an atom’s weight of good. The Prophet (Sallallahu Alaihi wa Sallam) said: "Allah will never be unfair to a believing person when he performs a good deed. He offers him a reward in this life and in the Hereafter. But the unbelieving person is fed in this life due to his good deeds for Allah’s Sake until he has no good deed left on the Reckoning Day." [Narrated by Muslim]
This Prophetic tradition clearly means that the rejecter of faith will be rewarded for his good deeds for Allah’s Sake before death, but in the Hereafter he will be a loser.
As for your question concerning people who heard of Islam but know nothing about it, and die as disbelievers, there are different opinions about them.
Dr. As-Sawi mentioned Islamic scholars’ opinions in his book ‘Ath-Thawabit Wal Mutaghayyirat’. Some of them confirm that such people will be tortured in the Hell-fire without a doubt. But others ascertain that they won’t be punished on Doomsday unless they have received the Message of Islam.
This opinion was certified by Ibn Al-Qayyim. Scholars, who ruled out accountability of those people for their deeds unless they receive the Message of Islam, are divided into two groups:
The first group of scholars say that their freedom of accountability on The Day of Judgment is absolute and will be encompassed by God’s Mercy first.
Al-Ghazali said, 'I say: Most Roman Christians and Turks in this time Allah May encompass them with Mercy, if He Wills. I mean those people who live faraway and didn’t hear the call of Islam. They are divided into three categories:
First category: Those who didn’t hear of Muhammad’s name, peace and blessings be upon him.
Second category: People who heard of the Messenger’s descriptions and accomplishment of miracles. They live near Muslim Lands and mix with Muslims. They are considered atheistic unbelievers.
Third category: Those who occupy a position between the two first categories. They heard Muhammad ’s name, but did not hear about his descriptions. They certainly heard from that disbelieving neighbourhood of “a liar” since their childhood – We seek refuge in Allah – who alleged Prophethood, as our (we Muslim) children heard of liar called Al-Muqaffa (who claimed to be Prophet (Sallallahu Alaihi wa Sallam)). Allah Sent him in defiance with Prophethood. These are, in my sight, in their traits belong to the first category.'
Although they had never heard of his name, they heard of what was contrary to his traits. This does not change reviewing the request. Some of the scholars said, 'They will be tried in the horrifying judgment seat on the Dooms Day.'
Some texts were authentic with regard to this subject. It was confirmed by many Islamic learned men like Ibn Taymiyyah, Ibn Al-Qayyim, Ibn Hajar, Ibn Hazm, Ibn Kathir and Al-Bayhaqi. Abu Al-Hassan Al-Ash’ari refered it to the people of As-Sunnah and Jamaa’.
The Prophet (Sallallahu Alaihi wa Sallam) said: "On the Day of the Resurrection, four kinds of people will dispute." A deaf man, a mad man, a man in the feeblest old age and a man who died in natural disposition. The deaf says, ‘Oh, my God! Islam came to me but I couldn’t hear anything of it’. The mad man says, ‘Oh, my God! Islam came while children were slinging excrement of camels at me’. The man of the feeblest old age says, ‘Oh, my God! Islam had come while I was bad at understanding. As for that the one who died in the innate peculiarity of character he says, Oh, my Lord! I didn’t hear of your Messenger. Then, they make a solemn covenant with Allah to obey Him.
After that, He sends to them a Messenger saying to them: ‘Enter the Hell-fire’. The Prophet (Sallallahu Alaihi wa Sallam) said, "By Whom my soul in His hands, if they enter the Hell-fire, they will find it cool and peaceful."
Ibn Kathir (May God encompass him with His Mercy) after mentioning texts indicating those people’s trial in the horrifying judgment seat on the Dooms Day – said, 'This saying combines all evidences. The afore-mentioned Prophetic traditions support one another. This saying which was narrated by Sheikh Abul-Hassan Ali Bin Ismael Al-Ash’ari upon the people of Sunnah and the community, and whose saying was confirmed also by Al-Hafith Abu-Bakr, Al-Bayhaqi in his book: ‘The Belief’ and other high-learned scholars of Islam.'
Allah knows best.