No good deeds are accepted from those who die as disbelievers even if they would spend the [whole] capacity of the earth in gold in what they think as a charity.
“A’isha (may Allah be pleased with her) narrated: I said: Messenger of Allah, the son of Jud’an established ties of relationship, fed the poor. Would that be of any avail to him? He said:
It would be of no avail to him as he did not ever say: O my Lord, pardon my sins on the Day of Resurrection[1].”
So, never would the [whole] capacity of the earth in gold be accepted from one of them if he would [seek to] ransom himself with it. Moreover, the Almighty says:
{ وَلَا يُقْبَلُ مِنْهَا عَدْلٌ وَلَا تَنفَعُهَا شَفَاعَةٌ وَلَا هُمْ يُنصَرُونَ}
(and no compensation will be accepted from it, nor will any intercession benefit it, nor will they be aided.) (Al-Baqara: 123)
{ إِنَّ الَّذِينَ كَفَرُوا لَوْ أَنَّ لَهُم مَّا فِي الْأَرْضِ جَمِيعًا وَمِثْلَهُ مَعَهُ لِيَفْتَدُوا بِهِ مِنْ عَذَابِ يَوْمِ الْقِيَامَةِ مَا تُقُبِّلَ مِنْهُمْ ۖ وَلَهُمْ عَذَابٌ أَلِيمٌ}
(Indeed, those who disbelieve – if they should have all that is in the earth and the like of it with it by which to ransom themselves from the punishment of the Day of Resurrection, it will not be accepted from them, and for them is a painful punishment.) (Al-Maaida: 36)
This states that nothing will save the disbelievers from Allah’s punishment, even if they redeemed themselves by the whole capacity of the earth of gold or by as much as its mountains, hills, dirt, sand, plain, rugged, land and sea weigh of gold. Prophet Muhammad (saws) said:
“Allah will say to the person who will have the minimum punishment in the Fire on the Day of Resurrection, ‘If you had things equal to whatever is on the earth, would you ransom yourself (from the punishment) with it?’ He will reply, Yes. Allah will say, ‘I asked you a much easier thing than this while you were in the backbone of Adam, that is, not to worship others besides Me, but you refused and insisted to worship others besides Me[2].’”
[1] Hadith no. 214, Chapter: The evidence that whoever dies upon disbelief, no good deed will benefit him. The Book of Faith, Sahih Muslim
[2] Hadith no. 12311, Musnad Anas bin Malik, Musnad the many companions, Musnad Ahmed Bin Hanbal.