In the Talmud (Berachot 5a), Rabbi Yitzchak is quoted saying: "Whoever recites the Bedtime Shema is as though he held a two-edged sword in his hand [to protect him against demons]...” While it is a Torah commandment to say the Shema (Hear O’ Israel the Lord Our God the Lord is One) twice a day, it is also customary to recite it before retiring in the evening.
In addition to the Shema and the V’ahavta paragraph that follows it, the complete “Bedtime Shema” includes additional prayers that focus on asking for God’s protection during the hours of sleep. One of the best known of these prayers is Hamalach Hago’el:
“May the angel who redeems me from all evil, bless the youths, and may my name be declared upon them--and the names of my forefathers, Abraham and Isaac--and may they proliferate like fish within the land” (Genesis 48:16).
This verse is a direct quote of what the dying Jacob said when he blessed his Egyptian born grandsons, Ephraim and Menashe. Jacob foresaw through prophecy that they would be the prototypes of so many of his descendants, born in exile. He therefore called on God to give them a special angel (divine messenger) to protect them.
While there is no official reason given that explains why the prayer “Hamalach” was added to the Bedtime Shema, perhaps one could conjecture that it has to do with how vulnerable people are when they sleep. Sleep could, in fact, be seen as a time when the soul is in “exile.”
Because of its reference to youth, this particular prayer is a popular children’s lullaby, as well. Many parents put their children to sleep by reciting the Shema to them or with them, followed by this soothing petition for Divine protection.