Reason of revelation:
Ibn Abbas (may Allah be pleased with him) said:
“A man from the Ansar converted to Islam, then he apostatized. After that, he regrated and requested his people, saying: ‘ask the Messenger of Allah (saws) is there any repentance for me?’ Then, the verse (How shall Allah guide a people who disbelieved after their belief ….) to (….. Except for those who repent after that and correct themselves. For indeed, Allah is Forgiving and Merciful. ) was revealed.”
(… كَيْفَ يَهْدِي اللَّهُ قَوْمًا كَفَرُوا بَعْدَ إِيمَانِهِمْ وَشَهِدُوا أَنَّ الرَّسُولَ حَقٌّ وَجَاءَهُمُ الْبَيِّنَاتُ ) (How shall Allah guide a people who disbelieved after their belief and had witnessed that the Messenger is true and clear signs had come to them? …): Arguments and proofs that proved the truthfulness of what the Messenger called for and explained to them. Then they apostatized to the darkness of polytheism. So, how do these people deserve guidance after they have worn the blinds? For this reason, the Almighty says at the end of the verse:
( وَاللَّهُ لَا يَهْدِي الْقَوْمَ الظَّالِمِينَ … ) (…And Allah does not guide the wrongdoing people.).