"Only take heed to yourself" (Deuteronomy 4:9). If you guard the words of the Torah, the Holy One, blessed be He, guards your soul; and if not, the Holy One, blessed be He, does not guard your soul. "And make them known to your children" (Deuteronomy 4:9). And it is written after it, "the day that you stood before the LORD your God" (Deuteronomy 4:10) — to teach you that anyone who teaches his son Torah, the Holy One, blessed be He, reckons it for him as if he had received it from His hand at Mount Sinai.
Guard the Torah and God Guards Your Soul at Sinai
Midrash Aggadah, Deuteronomy 4:9
רק השמר לך. אם אתה שומר דברי תורה, הקב"ה ישמור נפשך, ואם לאו אין הקב"ה שומר נפשך: והודעתם לבניך. וכתיב בתריה יום אשר עמדת לפני ה' אלהיך, ללמדך שכל המלמד את בנו תורה, מעלה עליו הקב"ה כאלו הוא קיבלה מידו מהר סיני: