1.The Passages of the Bedtime Shema
The Chachamim teach (Berachot 60b), "One who goes to sleep in bed must recite Shema Yisrael until V’Hayah Im Shamo’a, and the blessing Baruch HaMapil Chevlei Sheinah…." Likewise, Rabbi Yehoshua ben Levi says, "Even if a person recited Keriat Shema in the synagogue, it is a mitzvah to recite it [again] on his bed." Chazal base their words on the verse (Psalms 4:5), "Meditate in your hearts [while] on your beds and be silent" (Berachot 4b).
Rabbi Yehoshua ben Levi was accustomed to reciting an additional two Psalms before his sleep: "Yoshev B’Seter Elyon" (Psalm 91) and "Hashem Ma Rabu Tzarai" (Psalm 3), which are useful in warding off the evil spirits (Shevuot 15b), and many follow his minhag. Further, throughout the generations, people became accustomed to adding on Psalms, verses, and prayers. Since these are late additions, there are differences between the nusachim of the various ethnic groups. Some say that it is good to recite the paragraph of V’Hayah Im Shamo’a as well, and others maintain that it is best to recite all three paragraphs. 1
To summarize, in accordance with the enactment of the Chachamim, it is necessary to recite the paragraph of Shema and Birkat HaMapil before one goes to sleep, but the remaining Psalms are not an obligation. The minhag to recite them became widespread because of the custom of Rabbi Yehoshua ben Levi (see Magen Avraham 239:2). 2
There are those who are strict to recite Birkat HaMapil immediately before they sleep, after reciting Shema and all the other verses. However, according to the custom of the kabbalists, Birkat HaMapil precedes Shema and the other verses. One who is concerned that he will fall asleep while reciting the prayers or before concluding them should start with Shema and HaMapil, thereby ensuring that before he falls asleep he recites the passages instituted by Chazal (see Mishnah Berurah 239:2).
2.The HaMapil Blessing
Regarding the recital of HaMapil, some are concerned that perhaps they will not fall asleep and their berachah will have been said in vain. However, in practice, the fact that the Chachamim instituted reciting HaMapil means that they were not concerned about this. The blessing is a thanksgiving berachah to Hashem about sleep, and even for a person who does not succeed in falling asleep, the expression of thanks is not made in vain (Chayei Adam 35:4). Still, l'chatchilah, the Chachamim instituted the recital of this berachah for those who intend to sleep, and therefore one who has no intention of sleeping does not recite HaMapil on that particular night.
The HaMapil blessing is not recited on daytime sleep, although some say that it is good to say Viyhi No’am before a nap taken during the day (Mishnah Berurah 239:8 and see Bei’ur Halachah "Samuch"). HaMapil is also not recited on a temporary sleep at night. However, sleeping in one’s bed for half an hour or more is considered a regular sleep (Eshel Avraham 239; Beit Baruch 35:10). A person who went to sleep at night after reciting HaMapil, arose later to attend to certain matters, and then went back to sleep, does not repeat the HaMapil blessing, since HaMapil is only recited once a night (Beit Baruch 35:9; Piskei Teshuvot 239:1, note 4). One who fell asleep without reciting HaMapil, and woke up in the middle of the night with the intention to continue sleeping, must recite the berachah before falling asleep again. If he does not wish to get up from his bed and wash his hands, he may rub his hands on his blanket and then recite it (Shulchan Aruch Orach Chaim 4:23; Mishnah Berurah 61; unlike Piskei Teshuvot 239:1 who maintains that washing one’s hands is a requirement).
There are those who learned, based on the Kabbalah of the Arizal, that only a person who goes to sleep before chatzot (halachic midnight) recites the HaMapil blessing, and whoever goes to sleep after chatzot does not. Hence, many Sephardim are accustomed to reciting HaMapil without Shem u’Malchut (Hashem’s Name) when going to sleep after chatzot (Kaf HaChaim 239:8; see Yechaveh Da’at, part 4, pp. 122-124). However, according to the Ashkenazic minhag and that of some Sephardim, as long as one goes to sleep before amud hashachar, HaMapil is recited.
After reciting Shema and HaMapil, whoever must talk, eat, drink, or tend to an urgent matter is permitted to do so since Birkat HaMapil is unlike Birkot HaNehenin, concerning which it is forbidden to interrupt between the berachah and the pleasure derived. Rather, it is a berachah of praise on the night’s sleep. However, l'chatchilah, it is best to recite the bedtime Shema immediately before sleep (see Rama 239:1; Tzitz Eliezer 7:27; Yechaveh Da’at 4, pp. 118-122; Piskei Teshuvot 239:3; however Mishnah Berurah 239:4 is stringent after HaMapil).
One may recite the passages of the bedtime Shema while lying down, but he must be careful to lean on his side. There are a number of reasons why the Chachamim prohibited a man to sleep while lying on his back (Mishnah Berurah 239:6). However, before one’s sleep, a man is permitted to read a book while lying on his back and it is unnecessary for him to turn on his side. Only when he is about to fall asleep must he beware of lying on his back (Az Nidberu 6:50).
The Ba’alei Mussar (Jewish ethicists who composed books of reproof for the nation) wrote that it is good for a person to make a personal accounting (cheshbon nefesh) before sleep. If he remembers sinning, he confesses his sin and takes it upon himself not to sin in that manner again. It is also proper that before going to sleep, every person forgives anyone who sinned against him or caused him harm, so that no one is punished because of him. By doing so, one merits long life (Mishnah Berurah 239:9).
^ 1.The Chachamim instituted only the recital of the Shema paragraph before going to sleep, as the Rif (3:1), Rambam, and the Rosh (chapter 1, 6) write. However, in chapter 9, 23, the Rosh brings the opinion of Rabbeinu Chananel who maintains that V’Hayah Im Shamo’a is recited as well. Perhaps Rabbeinu Chananel understood the Gemara’s words "until V’Hayah Im Shamo’a" to mean, including V’Hayah Im Shamo’a. Divrei Chamudot 67 interprets that he is referring to a place in which Ma’ariv is recited before tzeit hakochavim, for there, in order to fulfill the mitzvah of Keriat Shema, it is necessary to recite both paragraphs. Rabbeinu Yerucham (netiv 3, part 2) and Rabbeinu Yonah in Sefer HaYir’ah write that all three paragraphs are recited, for together they contain 248 words, and saying them provides a special protection against harmful forces.
^ 2.It is written in Berachot 5a, "Rav Nachman says, One who is a talmid chacham need not [repeat Keriat Shema before going to sleep] (for his learning protects him). Abayei says that even a talmid chacham must say one verse concerning Hashem’s mercy, such as, ‘Into Your hand I entrust my spirit. You redeem me, Hashem, God of truth’ [(Psalms 31:6)]." The Rif and the Rosh agree that a talmid chacham is not obligated to repeat Shema. However, the Rambam and Shulchan Aruch do not mention this, implying that according to them, a talmid chacham must repeat it as well. Perhaps the source for their opinion is in the Yerushalmi (chapter 1, halachah 1) which discusses talmidei chachamim who were accustomed to reciting Keriat Shema a few times in order to fall asleep while saying Keriat Shema. Nevertheless, regarding the other verses, the recital of which is not obligatory, it seems that a talmid chacham can prefer to fall asleep while learning from a book or while deep in his thoughts. However, Kaf HaChaim 239:1 writes that by reciting the passages of Keriat Shema according to the Ari, a restorative act (tikun) is performed to the world and therefore even a talmid chacham must say them.