Laylat al-Mabīt (Arabic: لیلة المبیت) is the title of the night on which the Prophet (s) emigrated from Mecca to Medina. Quraysh had plotted to assassinate the Prophet (s), so he (s) began his emigration to Medina and 'Ali (a) slept in the bed of the Prophet (s), so the assassins would not notice his absence.
After the demise of Abu Talib, Quraysh polytheists intensified the harassment of Muslims. As the life of Muslims was in danger, the Prophet (s) ordered Muslims to emigrate to Medina. The Prophet (s) had recently made an allegiance with the people of Yathrib, so the Muslims were safe there. The Muslims started to emigrate to Medina covertly in small groups.
Chiefs of Quraysh gathered in Dar al-Nadwa to decide about their encounter with the Prophet (s); at last, with the plot of Abu Jahl, it was decided that selected brave men from all of tribes attack the Prophet (s) together and assassinate him at his home, so all the tribes have a part in the assassination of the Prophet (s) and Banu Hashim, who were his family and his avengers, could not fight all the tribes and have to accept the blood money.
Archangel Gabriel informed the Prophet (s) about the plot of Quraysh polytheists. He told 'Ali (a) about the situation and asked him if he would sleep in his place. 'Ali (a) said: "Will you be safe if I sleep there?". The Prophet (s) said: "Yes", so 'Ali (a) smiled and said: "Go as you are ordered, may my ears, eyes, and my very heart be sacrificed for you"
As Shi'a and Sunni scholars have narrated, the verse 207 of Sura al-Baqara is revealed about the night and the sacrifice of 'Ali (a) for the Prophet (s).
وَمِنَ النّاسِ مَن يَشري نَفسَهُ ابتِغاءَ مَرضاتِ اللَّهِ وَاللَّهُ رَءوفٌ بِالعِبادِ
And among the people is he who sells his soul seeking the pleasure of Allah, and Allah is most kind to [His] servants.
|— Quran 2:207|