71:4 If one did not recite the three paragraphs of Shema at night, he should then recite all three at when he goes to bed. (He must have specific intention to fulfill the mitzvah – Mishnah Brurah 239:1.) If he did recite them at night, he need only say the first paragraph at bed, though it is still preferable to say all three. Afterwards, one recites some Psalms and verses about G-d’s mercy, which appear in the siddur. Even though siddurim may have the bracha of HaMapil (that G-d closes our eyes) before Shema, it is better to say HaMapil at the end, right before going to sleep. (In practice, one may act either way – MB 239:2.) One should say Shema and the Psalms before going to his bed, and HaMapil on his bed. On the way to his bed, he should go to the mezuzah, places his fingers upon it, and say, “Hashem Shomri…” (“G-d is my Protector…”). After that, one recite “b’chol darchecha” (“in all your ways” – Proverbs 3:6) seven times. One should not eat, drink or talk after saying HaMapil until he falls asleep. If one cannot sleep, he should repeat Shema and the various verses of mercy, even several times, until he is overcome by sleep. (Mishnah Brurah 239:7 says that one should repeat the first paragraph of Shema but not the verse of Shema itself.) Others verses one might recite until overcome by sleep include Deuteronomy 33:4 “Moses commanded us the Torah…”), Leviticus 6:6 (“A constant fire…”), Psalms 119:113 (“I hate treacherous people…”) and Psalms 97:11 (“Light is sown for the righteous…”). A person’s intention in sleeping should be to renew his strength, the better to serve his Creator. If he does this, then his sleep is considered a way of serving G-d. If a person is going to have marital relations, he should not say HaMapil first. Rather, he should say at least the first paragraph of Shema and HaMapil after, before going to sleep (and after washing up – MB 239:5).
71:5 A person should not sleep in his clothes. When a person removes his clothes and shoes, he should remove the left side first. A person should not sleep with his clothes under his head, as this is believed to cause a person to forget the Torah he has learned. A person should accustom himself to sleeping on his side. It is advisable to start the night on one’s left side and finish it on his right. This was believed to be good for digestion based on the medical knowledge of the time.