God is Just, and He will reward the doers of good with paradise and the doers of bad with Hell in the hereafter, some of whom will remain in it ‘forever’. However some people question the concept of eternal punishment in hell fire. They claim that an eternal punishment for finite number of sins is not justified.
Although there is a minority opinion among muslim scholars who claim that the punishment in hell fire will end for all and the ‘forever’ is used in the context of the life of the hereafter and not eternity , the vast majority of scholars take it literally, understanding that the punishment in hell will last forever for the rejectors of truth, and will not end as per text of Quran and Sahih Hadith.
So now the question arises, as to how can God punish someone forever for a finite number of sins committed by the person. Is this justified?
In order to answer this question, let us answer a more basic question first – Who will enter hell fire? The question of everlasting hell fire is problematic for those who answer this question incorrectly, as they think that according to Islam all non-muslims will enter hell fire. However this is not true. God clearly says in the Quran
And never would We punish until We sent a messenger [Quran 17:15]
So the punishment of hell fire is only for those to whom the message of Islam has been conveyed clearly, along with its evidences and the warning of eternal hell fire has also been conveyed to them. Yet, after realizing the truth of Islam, if they still reject it out of arrogance or for material gain, then the punishment of hell fire is completely justified as they have willingly taken the punishment on themselves out of their arrogance for some immediate material pleasures.
As for those to whom the message has not been delivered, they will be tested for their obedience by God Himself. Those who obey God will enter paradise. As for those to disobey God, while they hear His command directly, will have chosen the hell fire for themselves. The following narration by the prophet is the evidence for it.
Anas said: the Messenger of God (PBUH) said: “Four (kinds of people) will be brought forth on the Day of Resurrection: the infant, the insane, the one who died during the period between two prophets (indicating the message did not reach them) and the very old man. All of them will speak in their own defence, then the Lord, may He be blessed and exalted, will say to a neck of Hell, ‘Come forth!’ and He will say to them, ‘I used to send Messengers to My slaves from amongst themselves. Now I am the Messenger of Myself to you. Enter this (i.e., the Fire).’ Those who are decreed to be among the doomed will say, ‘O Lord, how could we enter it when we are trying to escape it?’ And those who are decreed to be among the blessed will rush to enter it. And God will say: ‘You would have been more disobedient towards My Messengers.’ So those will enter Paradise and those will enter Hell.” Narrated by Abu Ya’laa, 4224. There are corroborating reports which were mentioned by Ibn Katheer in al-Tafseer, 3/29-31.