Due to the supreme sanctity of a Torah scroll, the Sages say that it must not be sold, and that one who sells a Torah scroll will never see blessing from that sale (Megilla 27a). Even when the owner of a Torah scroll has barely enough to eat, he should not sell it. Even if he does not have the money to buy necessary mitzva items, such as tefilin and mezuzot, he should not sell it (SA YD 270:1). Nevertheless, there are two mitzvot that are so important that, if one has no way to fulfill them without selling a Torah scroll, he may do so and use the proceeds for these mitzvot: Torah study and marriage. Even a community may sell its Torah scroll to marry off an orphan (SA 153:6; EH 1:2).
The unique quality of these two mitzvot is that they actualize the purpose of the Torah. Studying Torah brings the Torah’s words to life in people’s hearts, while marriage brings about the birth of children who will uphold the Torah (Megilla 27a).
This law does not come up often nowadays, because it is uncommon for a person to be unable to marry due to extreme poverty. There are always generous Jews who will help provide the basic necessities that enable the couple to wed. Nevertheless, this law teaches us the tremendous value of the mitzvot of marriage and procreation.
Some say that permission to sell a Torah scroll is limited to the case of someone who has not yet fulfilled the mitzva of procreation by having a son and a daughter (SA EH 1:8). According to many others, even someone who has already fulfilled the mitzva of procreation by having a son and a daughter may sell a Torah scroll in order to marry and have more children. This is the position of most Rishonim and Aḥaronim. Even if selling a Torah scroll will not provide a man with enough money to marry a woman of childbearing age, but only enough to marry a woman who cannot have children, some say he may not do so (Nimukei Yosef; Ritva), but others maintain that he may, as being married will enable him to become complete, fulfill the mitzva of ona, and protect himself from sinful thoughts (Ramban; Ḥelkat Meḥokek EH 1:10).
If one is selling a Torah scroll for the sake of marriage and children, it is more complicated. Several Rishonim understand Rif to say that a Torah scroll may be sold only to enable the fulfillment of the Torah commandment to have a boy and a girl. Indeed, this is the ruling in SA EH 1:8. Most Rishonim, though, maintain that a Torah scroll may also be sold to allow a person to have additional children. This is the opinion of She’iltot, Behag, and Rosh. Ramban agrees with this and thinks that the Rif does as well. Beit Shmuel 1:16 advocates this in practice. If selling a Torah scroll will provide a man with only enough money to marry a woman who cannot have children, then according to Nimukei Yosef and Ritva, he should not sell it. According to Ramban and Maharshal, he should. Ḥelkat Meḥokek, EH 1:10 agrees that the Torah scroll may be sold in this case, to save him from sinful thoughts. Terumat Ha-deshen §263 states that avoiding sinful thoughts is more severe than populating the world (shevet). This position is also reflected in Responsa Meshivat Nefesh 1:41, Pnei Yehoshua §42, and others.
Just as a Torah scroll may be sold to enable a man to marry and have children, it may also be sold to enable a woman to marry and have children. This is the case even if she already has children from a previous marriage. Although Ḥelkat Meḥokek, EH 1:1 states that we do not sell a Torah scroll to enable a woman to marry, since she is not obligated to procreate, Beit Shmuel, EH 1:2 permits the sale based on the mitzva to populate the world, a sweeping mandate that applies equally to both genders. This is the ruling of Responsa Maharam al-Ashkar §72, Knesset Ha-gedola, MA 153:9, Eliya Rabba 153:12, and MB 153:24. Additionally, a female orphan is married off before a male orphan, because she experiences the shame of poverty more acutely (Ketubot 67b; SA YD 251:8).