Must one divorce his wife if he has been married for 10 years without children?
From the letter of the law, if a man has been married for ten years and has not yet had children, then in certain circumstances the couple must get divorced and are forced to do so by the Beis Din. Nevertheless, the age-old custom of several generations is not to be particular about matches, and hence we no longer force such a couple to get divorced when they do not have children [and rather the couple remains married]. [Many Gedolei Yisrael, and G-d fearing Jews, have remained married after ten years despite not having children.]
Why may one remain married, if the marriage cannot bear children?
The Rebbe related the following in a letter addressed to a couple who was childless after ten years: It is written in the holy Sefarim, in particular in the Sifrei Kabalah, that although one must do all that is necessary to fulfill the Mitzvah of Peru Urevu, there are certain cases of exception in which G-d exempts one from doing so. The reason for this is because he has a different purpose in his life [that G-d has destined for him]. The Shlah Hakadosh writes in the name of Rav Shlomo Alkabetz that Hashem sends certain souls into the world for a specific Tikkun, or leadership positions, which exempts them from having children. Not only do they not need to have children, and will not get punished for not having children, but even if they have children, the children will not spiritually be considered as theirs for any purpose. This is why Ben Azaiy did not have children, as his purpose was solely for Torah learning.
Raising other children:
One who raises and educates a child is considered as if he gave birth to them, even if one is not their biological parent. This is learned from the Torah itself, from where we see that the holy foremothers gave their husbands other wives in marriage in order to raise the children that they will bear. Accordingly, a couple who cannot have children may adopt another’s child and be considered as if they gave birth to him. [However, prior to doing so, one must be aware of all the laws involved with an adopted child such as Yichud, affectionate touch etc.]
The Baal Shem Tov can argue on the Mishneh:
A Chassid once came to the Tzemach Tzedek, asking for a blessing, and the Tzemach Tzedek replied that only the Baal Shem Tov can affect such a miracle. The Tzemach tzedek related that the Baal Shem Tov was so powerful that he could argue on a Mishneh. Which Mishneh? The Mishneh which states that after ten years of marriage without children, a divorce is necessary, and in many cases the Baal Shem Tov effected that the couple have children even after ten years.
The Rebbe convinces a couple to stay married:
One morning in New York, in the early the 50’s or 60’s, the Rebbe took an unexpected ride with his wife the Rebbetzin. The curious Bochurim followed the Rebbe’s car to see where it would be heading. You see, in the early years the Rebbe was accustomed to walk home after Davening, and when the Bochurim saw the Rebbe get into the car with his wife they knew that something was astray. After about 20 minutes of driving, the Rebbe’s car pulled up to a driveway in front of a home in the Williamsburg neighborhood. The Rebbe and Rebbetzin left the car and entered the house. After the passing of a considerable amount of time the Rebbe and Rebbetzin exited the house and returned to Crown Heights. The curious Bochurim, knowing no limits to help quench their curiosity, knocked on the door of the house to try to receive some hint as to what transpired in the home. A middle-aged couple answered the door and asked how they can be of help. The Bochurim replied that they wanted to know as for what purpose the Rebbe visited their home. “Which Rebbe?” asked the couple. “The Lubavitcher Rebbe”, answered the Bochurim. “You mean that the couple who just visited my home was the Lubavitcher Rebbe and Rebbetzin?” asked the couple in astonishment. “Yes indeed it was,” replied the Bochurim, “and what is it that they told you?” Please come in and have a seat and we will explain. You see my wife and I are married for over ten years and we have not merited having children. We have thus seriously considered getting divorced, as is the ruling of the Shulchan Aruch. Today this respected couple came to our door, looking like a Rabbi and Rebbetzin, and persuaded us not to get divorced. The Rabbi explained that according to Halacha there is no need to get divorced today, and that even he and his wife are married for more than ten years without children, and they still remain married despite the letter of the law. The couple convinced us not to get divorced, and now I see that it was none other than the Lubavitcher Rebbe and his wife who came to visit us. All those present were left in astonishment seeing the Rebbe’s and Rebbetzin’s care for a couple they did not know, and how they troubled themselves to meet with them to help save their marriage.
 Michaber and Rama E.H. 154:10; Rama E.H. 1:3; Mishneh and Gemara Yevamos 64a
 From when are the years counted? The following times is not included as part of the ten years: Business trips; illness of husband or wife; imprisoned. [Michaber 154:11; Braisa Yevamos ibid] After a miscarriage the ten years restart. [Michaber 154:12] Some Rishonim rule that the ten years are only counted in Eretz Yisrael, and hence childless couples in the Diaspora are never required to get divorced. [Hagahos Maimanis Ishus 15:4 in name of Ravayah; Tosafus; Sefer Hateruma and Raavan; Semag Assei 49; See Bigdei Kehuna 1, brought in Pischeiy Teshuvah E.H. 154:27] However, most Rishonim and Poskim do not differentiate between the Diaspora and Eretz Yisrael, and the ten-year count requires divorce no matter where one lives. [Implication of Rambam; Rif; Michaber ibid; See Aruch Hashulchan 154:24-25 for many proofs that it applies even in the Diaspora, and that all the Poskim agree to this] Nonetheless, if one moves from the Diaspora to Eretz Yisrael then the ten years restart. [Rashba in name of Raavad, brought in Aruch Hashulchan 154:25 and that so is the Halacha] Likewise, if one lives in Eretz Yisrael and travelled to the Diapsora, then his stay in the Diapsora does not count. [Poskim ibid]
 If they had children but did not fulfill Peru Urevu: Some Poskim rule that they must get divorced even if they had a child, or had children, but have not yet fulfilled the Mitzvah of Peru Urevu [i.e. boy and girl]. [Implication of Michaber ibid as understood from Rama’s gloss; Rashba; Nimukei Yosef; See Aruch Hashulchan 154:23] Other Poskim, however, rule that this only applies if no children have been born. If, however, they had a child, then although they did not fulfill the Miktzvah of Peru Urevu, they do not need to divorce. [Rama 154:10; Rambam Ishus 15; Rivash 15:1] Some Poskim, however, limit this leniency only to a case that the wife can still have children, otherwise he must divorce her. [Beis Shmuel 154:24] Other Poskim, however, are lenient in all cases, and so is the custom. [Meil Tzedaka 33, brought in Pischeiy Teshuvah E.H. 154:26]
Miscarriages: Although a miscarriage restarts the ten-year count, if a woman had three consecutive miscarriages, then they are to get divorced [in even less than ten years]. [Michaber 154:12]
If he had children from a previous marriage: If the husband has children [boy and girl] from a previous marriage, then he may remain married to his wife even after ten childless years. [See Michaber 154:17]
 Cases of exception: If the man knows that he cannot have children, then there is no need for him to get divorce, as in any event he cannot fulfill the Mitzvah of Peru Urevu. [Rama 154:10] Some Poskim rule that if the couple desires to remain married and the Kesuba settlement is very expensive or the wife helps support his Torah learning, then they are not required to get divorced. [Bigdei Kehuna 1, brought in Pischeiy Teshuvah E.H. 154:27]
Does this law apply in the Diaspora? See previous footnotes!
 Marrying a second wife: Alternatively, rather than get divorced, one can marry a second wife who can have children [and live with both wives]. [Michaber ibid] This option is not viable for Ashkenazi Jewry due to the Cherem of Rabbeinu Gershom unless the wife refuses to get divorced, in which case he may marry a second wife based on Heter Meiah Rabbanim. [see Noda Beyehuda Tinyana 102; Pischeiy Teshuvah E.H. 154:25; Aruch Hashulchan 1:25] However, it is viable for Sefaradi Jewry, and so has been done in numerous cases through the Israeli Rabbinate. [See Yabia Omer E.H. 7:2] See letter in Likkutei Sichos 15:480, printed in Shulchan Menachem 6:59, written to a Sefaradi man asking if he can marry a second wife being that they have not had children in ten years “You need to receive a ruling from the Sefaradi Rabbanim to allow you to take a second wife. I, as an Ashkenazi, cannot write you such an allowance. However, according to Sefaradi custom, as you write, it is easier to receive an allowance. Nonetheless, you must try to appease your wife by a) explaining to her that not everyone’s purpose in this world is to have children, and b) By raising other children, such as his new wife’s children, Hashem considers it as if she is raising him; c) You should write a Sefer Torah in the merit of your wife.”
 Michaber and Rama ibid; Mishneh and Gemara Yevamos 64a that must divorce; Rav Tachlifa in Kesubos 77a that Beis Din forces him to divorce
The reason: As a man is obligated to perform the Mitzvah of Peru Urevu, and the Sages estimated that if a woman did not have children in ten years, most like she never will. [Aruch Hashulchan 154:23]
 Although the implied ruling of Rama/Rivash is simply that we do not force a divorce, although ideally they should get divorced [see Bigdei Kehuna 1, brought in Pischeiy Teshuvah E.H. 154:27], nonetheless, the custom is not to get divorced.
 Rama 1:3; 154:10; Rivash 15; Hagahos Maimanis Ishus 15:4 in name of Ravayah [Aviasaf] “We no longer force to divorce even in the Israel as the Talmud states that after the destruction it would have been proper to decree not to have children and hence at the very least we do not force a divorce upon such a couple.”
 Likkutei Sichos 15:480, printed in Shulchan Menachem 6:59
 See Zohar Vayeishev 188b; Shaar Hagilgulim Hakdama 3; Shlah Hakadoshj in next footnote
 Shlah Hakadosh p. 381 [Parshas Ki Seitzei gloss from Rav Shlomo Alkabetz]
 See Likkutei Sichos 15:480, printed in Shulchan Menachem 6:59; Bigdei Kehuna 1, brought in Pischeiy Teshuvah E.H. 154:27, in end of Teshuvah
 Sefer Hatzetzaim p. 123 as heard from Chassidim
 Heard from Rav S.Z. Labkowski, R.Y. of central T.T. Yeshiva N.Y, who was one of the Bochurim involved
Was there any ever insight given as to why this Gezerah was abolished?