“And there is the type of man who gives his life to earn the pleasure of Allah: And Allah is full of kindness to (His) devotees.” (Holy Quran; Surah al-Baqara, Verse 207)
This verse was revealed on the first night of the month of Rabi al-Awwal in praise of Imam Ali (AS). On that night, the Holy Prophet (PBUH) started his emigration from Makkah to Madinah as the Mushrikeen (infidels) of Makkah had conspired to assassinate the Prophet (PBUH).
And Imam Ali (AS), the hero of all times, put his life at risk by sleeping in the place of the Prophet (PBUH).
That was Laylat al-Mabit (the night of sleeping).
Ahmad al-Ghazali (1061–1123 AD) writes in his book “Ihya Ulum al-Din” (revival of religious sciences):
On the night when Amir al-Muminin (the Commander of the Faithful) slept in the place of the Prophet (PBUH), the angels Jibraeel and Mikaeel were told (by God) that He had established brotherhood between them and decided that one of them live longer than the other.
“Which one of you makes a sacrifice so that the other lives longer?” God asked them.
Both of them said they wanted to be the one who lives longer.
They were told: Look upon the earth and see how Ali (AS) has (put his life at risk) and slept in the place of his brother, the Prophet (PBUH). Go to the earth and protect him against enemies.
They did so and congratulated Imam Ali (AS), saying “God has boasted of you to the angels.
It was here that the verse “And there is the type of man who gives his life to earn the pleasure of Allah…” was revealed.
Ihya Ulum al-Din; Ghazali, Book VII, On Self Sacrifice