From the great Adhkar (invocations and Remembrances said at certain times on a regular basis) which the Prophet (peace be upon him) used to say at sleeping and at waking up from sleep is the Hadith reported in Sahih Al Bukhari on the authority of Hudhayfah ibn Al Yaman (may Allah be pleased with him) who said: "Whenever the Prophet (peace be upon him) intended to go to bed, he would recite: "Bismika Allahumma amutu wa ahya (With Your name, O Allah, I die and I live)." And when he woke up from his sleep, he would say: "Al hamdu lil-lahil-ladhi ahyana ba'da ma amatana; wa ilaihi an-nushur (All the Praises are for Allah Who has made us alive after He made us die (sleep) and unto Him is the Resurrection)." (Hadith No: 6324).
In another wordings: "Whenever the Prophet (peace be upon him) went to bed every night..." (Hadith No: 6312).
In another wording: "Whenever Allah's Messenger (peace be upon him) went to bed." (Hadith No: 6314) and all narrations are the same.
As for his saying: "Bismika Allahumma" (With Your Name, O Allah). The meaning is: I go to sleep seeking Your Help, Your Preservation, and seeking protection, safety, and good health from You. As for his saying: "I die and I live," it means: In all cases I shall mention Your Name because by mentioning Your Name I shall live or I shall die. The Hadith contains a reference for a Muslim that he cannot do without mentioning Allah upon his sleep, when he wakes up, and in all his affairs and conditions. A Muslim concludes his actions by mentioning Allah, and when he wakes up, he mentions Allah as his first action, then he keeps on mentioning Allah in all his conditions, so, he shall live, die, or being resurrected on the Day of Recompense as mentioning Allah in all his conditions.
As for his saying: "Bismika Allahumma Amutu" when a person wants to sleep in reference that sleep is called death and one of its kind even if a person is still breathing. Allah (may He be Exalted) says: "It is Allâh Who takes away the souls at the time of their death, and those that die not during their sleep. He keeps those (souls) for which He has ordained death and sends the rest for a term appointed. Verily, in this are signs for a people who think deeply." [Surat Az-Zumar: 42]. Therefore, the Messenger of Allah (peace be upon him) said at the end of this Hadith: When you wake up, you should say: "Praise be to Allah who gave us life after He had caused us to die." referring to the state of sleeping which a person has been through. A sleeping person looks like a dead person because he stops moving and you cannot distinguish between him and the dead, therefore religious burdens are lifted from the sleeping person until he wakes up from sleep.
Sleeping is one of the great signs of Allah which indicate the perfection of His Creation, Greatness, and that He is the only one deserves to be worshiped. He is the Ever-Living who does not die and neither slumber nor sleep overtakes Him. Allah (may He be Glorified and Exalted) says: "And among His Signs is your sleep by night and by day, and your seeking of His Bounty. Verily, in that are indeed signs for a people who listen." [Surat Al `Ankabut: 23].
Of His Mercy with His Servants that He gave them a time for rest and recreation as Allah (He may be Glorified) says: "It is out of His Mercy that He has made for you the night and the day that you may rest therein (i.e. during the night) and that you may seek of His Bounty (i.e. during the day) - and in order that you may be grateful." [Surat Al Qasas: 73].
Of the great benefits of sleep is that it reminds man of death which is the end of all people and the final destination of every living being except (Allah) the Ever-Living who does not die. Waking up from sleep is an indication to the power of Allah (Glory be to Him) and His Ability to resurrect bodies after their death and giving them life, therefore the Prophet (peace be upon him) said at waking up: "Al hamdu lil-lahil-ladhi ahyana ba'da ma amatana; wa ilaihi an-nushur (All the Praises are for Allah Who has made us alive after He made us die (sleep) and unto Him is the Resurrection)." The Prophet (peace be upon him) drew the attention to wakefulness after sleep, which is a kind of death as mentioned above to prove resurrection after death when the people stand before the Lord of the worlds [i.e., people]. Therefore, it was authentically reported in Al Adab Al Mufrad from the Hadith of Al Bara' ibn `Azib that he said: "When the Prophet (peace be upon him) wanted to go to sleep, he put his hand under his right cheek and said: O Allah, protect me from Your punishment on the Day you raise up Your slaves." Al Adab Al Mufrad (No. 1215) and Al Albany (may Allah bestow mercy on his soul) graded it as authentic in Sahih Al Adab Al Mufrad (No. 921).
As for his saying: "Praise be to Allah who gave us life after He had caused us to die," it contains thanking Allah for this great blessing which is giving life after death, meaning: Reawakening after sleep. It is well known that when a person sleeps, he does not benefit from this life and becomes unable to perform the acts of worship, but when he wakes up, this impediment is removed. So, he thanks Allah (may He be Glorified and Exalted) for this blessing and for this great gift.
What is beautiful and is in harmony with this meaning is the Hadith which was reported by Al Bukhari and Muslim on the authority of Abu Hurayrah (may Allah be pleased with him) who said: The Prophet (peace be upon him) said: "When anyone of you go to bed, he should shake out his bed with the inside of his waist sheet, for he does not know what has come on to it after him, and then he should say: 'Bismika Rabbi wada`tu Janby wa bika Arfa`uhu (In Your name my Lord, I lie down), In amsakta nafsy farhamha (if You keep myself, show mercy to it) wa in arsaltaha fahfazha bima tahfazu bihi ibadakas-salihin (and when You let it go, protect it as You protect Your Righteous Servants)." Sahih Al Bukhari (No. 6320) and Sahih Muslim (No. 2714).