The Messenger of Allah (peace be upon him) said, “When any of you goes to bed, he should shake off (or dust off) his bedsheets because he does not know what might have fallen on it after he had left it. Then he should recite: ‘Bismika Rabbi wada’tu janbi, wa bika arfa’uhu, in amsakta nafsi farhamha, wa in arsaltaha fahfazha bima tahfazu bihi ‘ibadakas-salihin [With Your Name, my Rubb, I place my side (upon the bed) and with Your Grace I will raise it up. If You withhold my soul (cause me to die), have mercy on it but if You let it go (let me live), guard it against which You guarded Your pious servants].”‘
[Al- Bukhari and Muslim].
Sheikh Raslan commented, “People, unfortunately, are not aware of the Prophet’s life; he taught us every little thing. However, those bestowed with success strive to investigate the Prophet’s life (peace be upon him); the follow the knowledge they acquire and implement it, and thereby they are rewarded with the best of rewards. On the other hand, those who claim loving the Prophet (peace be upon him) while being ignorant of his life and how did he managed to live it; their claim must be revisited and reconsidered.
The reason for shaking off the bedsheets lies in the potential possibility that there could be something harmful on the bedsheets you’re not aware of its presence; this thing could harm you. However, the Prophet (peace be upon him) teaches you to check your bedsheets before you go to sleep. He guides you towards what is best for you even in this life. Not only you get to benefit from doing so, but also top this with the benefit Allah confers upon you as a reward for the Dhikr (remembrance) you recite when you get to sleep.”
Source: Sunnan Mahjoorah [Deserted Sunnan of the Prophet (?)] by Sheikh Muhammad Said Raslan: pages: 27-28.