Praise be to Allah, and may peace and blessings be upon the Messenger of Allah. To proceed:
There is no contradiction between Allah’s mercy and His punishment of the disbeliever and his eternal stay in Hell, because Allah’s mercy, justice, and wisdom are all attributes of perfection and do not contradict one another.
Allah’s Mercy Is of Two Types
There is a general mercy in this worldly life that encompasses all creation, believers and disbelievers alike. Allah provides for them, grants them well-being, and gives them respite.
There is also a special mercy in the Hereafter, which Allah grants to the believers who believe in Him and follow His messengers.
Allah Almighty says:
“My mercy encompasses all things, but I will decree it for those who fear Me.”
Al-A‘raf: 156.
Why Will the Disbeliever Remain in Hell Forever?
Allah Almighty is the Most Merciful of those who show mercy. He sent the messengers, revealed the scriptures, and established the proof for His servants. Whoever believes deserves His special mercy, while whoever dies upon disbelief after the proof has been established against him has deprived himself of that mercy.
If Allah were to make the believer and the disbeliever equal in their recompense, this would be contrary to His justice and wisdom. Allah Almighty says:
“Should We then treat the Muslims like the criminals?”
Al-Qalam: 35.
Conclusion
Allah Almighty is more merciful to His servants than a mother is to her child, but His mercy does not contradict His justice and wisdom. His special mercy in the Hereafter is for the believers. As for the one who dies upon disbelief after the proof has been established against him, he is punished according to Allah’s justice, not because of any injustice on Allah’s part. Therefore, there is no contradiction between the perfection of His mercy and the perfection of His justice.
And Allah knows best.