The Sages say, “One who teaches Torah to someone else’s child is considered by the Torah as if he gave birth to him.” Whereas Aharon gave birth to his sons, Moshe Rabbeinu taught them Torah, so they are called his sons as well (Sanhedrin 19b).
Similarly, it is written in Shema, “Teach them to your children” (Devarim 6:7). The Sages interpret:
“Your children” – refers to your students. We find that students are referred to as children in many other places as well, as it says, “Then the sons of the prophets at Beit El came out to Elisha” (2 Melakhim 2:3). Were they the prophets’ children? Rather, they were their students. We derive from this that students are called children…. Just as students are called children, so too teachers are called parents. Thus, we read (ibid., 2:12), “Elisha saw and cried out: ‘Father, father! Israel’s chariots and horsemen!’ Then he did not see him again.” (Sifrei)
This notion has halakhic significance as well. If someone finds two lost objects, one belonging to his father and the other to his teacher, and he is unable to return them both, his teacher’s lost object takes precedence, “because his father brought him into this world, while his teacher, by teaching him Torah, brings him into the next world.” However, if his father is also a Torah scholar, then his father’s lost object takes precedence (Bava Metzi’a 33a).
According to Zohar (I 187b), in the verses we saw above (7:6), the prophet Yeshayahu addresses those who are not privileged to have children:
For thus said the Lord: “As for the eunuchs who keep My Sabbaths, who have chosen what I desire and hold fast to My covenant – I will give them, in My House and within My walls, a monument and a name better than sons or daughters. I will give them an everlasting name which shall not perish.” (Yeshayahu 56:4-5)
A story is told about how R. Yoḥanan was distraught after all of his children died young and he had not fulfilled the mitzva of procreating. Then an elder comforted him by saying that his students were considered his children, and in their merit he would have a place in the next world and an everlasting name (Zohar Ḥadash, Ruth, 108b).
Those who support Torah students are also considered their teachers, for without them, the students would be unable to learn.
According to Sefer Ḥasidim (§367), sometimes God does not want to deplete a person’s heavenly account. Therefore, he does not get to enjoy both Torah and children in this world. It is because he is not blessed with children that he can be blessed with Torah, which will give him an everlasting name.