All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Allah warns those who disobey His Commands against severe punishment; on the other hand, He Promises to grant them forgiveness if they return to Him and obey His Commands and instructions. Allah Says (what means):
• {And fear Allah; indeed, Allah is severe in penalty.} [Quran 59:7]
• {And cooperate in righteousness and piety, but do not cooperate in sin and aggression. And fear Allah; indeed, Allah is severe in penalty.} [Quran 5:2]
• {…ask forgiveness of Allah. Indeed, Allah is Forgiving and Merciful.} [Quran 2:199]
• {But whoever repents after his wrongdoing and reforms, indeed, Allah will turn to him in forgiveness. Indeed, Allah is Forgiving and Merciful.} [Quran 5:29]
These verses and many others show the great extent of Allah's Mercy and the scope of His Forgiveness for those who repent. They (verses) similarly bespeak His severe and unbearable Punishment for those who insist on sin without repenting. Yet, some points are to be taken into consideration in this regard:
1- Allah does never forgive anyone for polytheism; i.e., associating gods or peers along with Him in worship, unless he repents from this grave sin. Allah Says (what means): {Indeed, Allah does not forgive association with Him, but He forgives what is less than that for whom He wills. And he who associates others with Allah has certainly fabricated a tremendous sin.} [Quran 4:48]
As for sins lesser than that, if the wrongdoers give them up and repent to Allah, then He will forgive them. But if they do not give them up, then they will be under Allah's will; He either forgives them or punishes them.
2- Allah's Mercy surpasses His Wrath and Punishment. According to an authentic Hadeeth: After Allah completed the formation of the creation, He wrote in His Book (Preserved Tablet) which is over the Throne that 'My Mercy has surpassed My Wrath.’ [Al-Bukhari]
3- Allah Forgives whomever He pleases and punishes whomever He pleases. Nothing is compulsory on His Majesty. None has the ability to argue or reject His Commands. Allah Says (what means): {…Then He will forgive whom He wills and punish whom He wills, and Allah is over all things competent.} [Quran 2:284] Allah Says (what means): {He forgives whom He wills, and punishes whom He wills. And Allah is Oft-Forgiving, Most Merciful.} [Quran 3:129] Allah has stated the conditions of forgiveness such as repentance, regret for what the sinner has done, doing righteous deeds frequently, asking forgiveness frequently, and persistently entreating and supplicating Allah for forgiveness. Allah Says at the tongue of Prophet Noah (what means): {And said, 'Ask forgiveness of your Lord. Indeed, He is ever a Perpetual Forgiver. He will send [rain from] the sky upon you in [continuing] showers. And give you increase in wealth and children and provide for you gardens and provide for you rivers.} [Quran 71:10-12] In another verse, Allah Says (what means): {The revelation of the Book is from Allah, the Exalted in Might, the Knowing. The forgiver of sin, acceptor of repentance, severe in punishment, owner of abundance. There is no deity except Him; to Him is the destination.} [Quran 40:2-3] Besides, Allah Says in an authentic Qudsi Hadeeth (i.e. the meaning of which is from Allah and the wording is from the Prophet (): “O son of Adam! Whenever you call on me and entreat me, I will forgive you without measure, no matter what you did. O son of Adam! Even if your sins (are so abundant that they) reach the sky then you ask My Forgiveness, I will forgive you without measure. O son of Adam! If you commit sins the earth size (so much so that they cover the earth) then you meet me without associating anything with Me in worship, verily I will meet you with (the earth-size of) forgiveness (in similar abundance).” [At-Tirmithi, and Al-Albani classified it as authentic]
Allah knows best.