1) HALACHAH: WHEN MAY A SEFER TORAH BE SOLD?
OPINIONS: Rebbi Yochanan says in the name of Rebbi Meir that a Sefer Torah may not be sold except for two purposes: to raise funds to enable one to learn Torah or to get married.
The Gemara attempts to prove from this ruling that one may sell an old Sefer Torah in order to buy a new one, because buying a new Sefer Torah is equated with using the funds to learn Torah. The Gemara rejects this proof and says that buying a new Sefer Torah is not comparable to using the funds for learning Torah. Learning Torah is greater because it enables one to fulfill the Torah in practice.
(a) The Gemara leaves its question -- may one sell an old Sefer Torah in order to buy a new one -- unanswered. What is the Halachah in practice?
(b) May a Sefer Torah be sold for any other Mitzvah, such as Pidyon Shevuyim (the redemption of captives)? Similarly, may a Sefer Torah be sold in order to provide sustenance for the poor?
(c) May a Sefer Torah owned by an individual (as opposed to one owned by the community) be sold?
(d) When a Sefer Torah was originally purchased (such as by a merchant) with an expressed condition that it will be resold, may it be resold?
(e) When a Sefer Torah is found to be invalid, may it be sold in order to help raise money to buy a new Sefer Torah?
HALACHAH:
(a) The Gemara clearly rules that if the new Sefer Torah is not yet ready, the old one may not be sold (because an unforeseen mishap may occur which will leave the community without a Sefer Torah). The Gemara's doubt applies only when the new Sefer Torah is ready to be purchased.
The SHACH (YD 270:3) rules that an old Sefer Torah may not be sold in order to buy a new one, even when the new one is ready. He explains that one must be stringent because the Gemara leaves this question unanswered. (This reasoning is based on the RAN and ROSH's understanding of the RIF.) RAV MOSHE FEINSTEIN zt'l (Igros Moshe YD 3:113) points out that even though the prohibition against selling a Sefer Torah is only mid'Rabanan, nevertheless one must be stringent because of the honor of the Torah.
However, the LEVUSH and TAZ permit an old Sefer Torah to be sold when there is no concern that the community will be left without a Sefer Torah.
In practice, Rav Moshe Feinstein (ibid.) rules like the Shach. (See also DERISHAH, end of YD 270:2.)
(b) TOSFOS in Bava Basra (8b, DH Pidyon Shevuyim, cited by the GILYON HA'SHAS here) writes that a Sefer Torah certainly may be sold for the sake of Pidyon Shevuyim. Tosfos asserts that the reason why the Gemara here does not mention it is because it is obvious.
This is the ruling of the MAGEN AVRAHAM (OC 153:9). (The DERISHAH (YD 252:2), however, writes that when Tosfos says that a Sefer Torah certainly may be sold for Pidyon Shevuyim, he refers only to raising money for the Pidyon of oneself but not for others.) The MISHNAH BERURAH (153:24) points out that the Magen Avraham later (153:11) writes that a Sefer Torah may be sold for Pidyon Shevuyim only as a last resort, when there is no other way to raise the money needed. This is the ruling of the RAMBAM and SEMAG.
According to the RAMBAM (Hilchos Sefer Torah 10:2), a Sefer Torah may not be sold even to provide food for poor people who have nothing to eat. The HAGAHOS MAIMONIYOS questions the Rambam's ruling from the Yerushalmi (end of Bikurim) which explicitly states that a Sefer Torah may be sold in order to provide food for one who has nothing to eat. Moreover, the Gemara here quotes Raban Shimon ben Gamliel who says that one who sells a Sefer Torah in order to buy food (even if he has nothing else to eat) will see no blessing from the sale. This implies that one is not prohibited from selling a Sefer Torah to provide food, but just that he will see no blessing from the sale.
The BEIS YOSEF explains that the Rambam assumed that Raban Shimon ben Gamliel's statement that one will see no blessing from such a sale implies that the sale is prohibited. However, the Beis Yosef seems to conclude like the Hagahos Maimoniyos that one may sell a Sefer Torah when he has no other source of funds to provide food for himself.
(c) The SHULCHAN ARUCH (OC 153:10) records two opinions with regard to whether or not a Sefer Torah owned by an individual may be sold. The MAGEN AVRAHAM writes that the common practice is to sell a privately-owned Sefer Torah even if it was used for the public Torah reading, because it is assumed that the owner gave it over for public use only on condition that he retain the right to sell it. The owner did not donate (Makdish) his Sefer Torah to the public, but rather he merely gave them permission to read from it (SHA'AR HA'TZIYUN 153:57).
(d) When a Sefer Torah is purchased with a specific condition that it be sold later, the Sefer Torah may be resold. This leniency also applies to one who receives a Sefer Torah as payment for a debt owed to him (MISHNAH BERURAH 153:62). In both cases, the seller may use the money for any purpose.
(e) RAV MOSHE FEINSTEIN (ibid.) rules that a Sefer Torah which is invalid may be sold in order to raise money to buy a new Sefer Torah.

OTHER D.A.F. RESOURCES
ON THIS DAF