What advice can be given to a couple that does not have children after several years of marriage?
Rav Moshe Sternbuch (in his “questions and answers” 4:203, 1:790) offers various suggestions, we will quote most of them. First of all, it is necessary to pray to the Creator, knowing that everything He does is for the best. Here are some concrete suggestions; some are based on medicine but the majority on Torah laws. It is necessary to check all Mezuzahs in the dwelling; the men should have their Tefillin checked. It is also necessary to check the Kesubah (the marriage contract), including whether their names were spelled correctly. It is desirable, that two Kohanim (when blessing the people) keep this couple in mind, that Hashem should send them children. Also, let a Mohel (the person, circumcising a child) and a Sandek (holding a child on a lap during circumcision) pray for them before Bris Milah that they should merit to have children. The husband should read the parsha of “ketores” from a parchment (i.e., the Torah passage that we read in the beginning of morning and afternoon prayers, should be read from a parchment, not just from a Siddur; many synagogues have such parchments). The couple should invite more guests. Before lighting the Shabbos candles, the woman should read the prayer of Chanah (the second part of the book of Shmuel, chapter 2, verses 1-10). Before going to the Mikvah, the woman should make a monetary donation (tzedoko) for those, studying Torah, and pray to Hashem that she merits having children. The husband should take on himself an obligation, that if a child is born, he will recite with great concentration the prayer "Nishmas Kol Chai" – the souls of all living will bless You, Hashem.
If the problem is with the man’s sperm, he should sit for ten minutes in cold water before relations. It also helps to eat fried garlic prior to relations. (Many eat fish with garlic.) The couple should stay away from smokers as nicotine is very harmful... There is a tradition to boil the Aravos (willow branches which they picked up during the holiday of Succos ) in water and to drink the solution since "Arava" has the same numerical value as "Zera" - sperm. It is necessary to drink at least a reviis (around 89 milliliters) and to pray to Hashem for children. The main thing is not to be nervous and not to be upset.
In case of miscarriages, the husband should say before reading of the Torah in the synagogue: "VEATEM HADVEKIM BADONOY ELOHEKHEM KHAYIM KULKHEM HAYOM" - "And you, who cling to God, are still alive". The pregnant woman should be especially cautious not to eat anything that may be not kosher (even in cases of certain foods where a dispute exists regarding their kashrus). According to Arizal it helps being especially careful to add to Shabbos both in the beginning and in the end (i.e. not to wait for the last moment to light the Shabbos candles, and after Shabbos to not begin work immediately, but to add to the Shabbos rest).
If all the aforesaid do not help, sometimes it may be advisable for them to take additional names; all this is done only at the advice of a knowledgeable Rabbi. Sometimes the husband is advised to take on himself voluntary fasts, to correct a possible "Pagam Habris" damage of the covenant, i.e. the sins connected to the organ on which circumcision was performed. This is the organ of the covenant, and sometimes damaging it is punished measure for a measure - the couple does not have children. Certainly, before fasting, it is necessary to repent and to make a firm decision not to look, where we are not supposed to (for example on those internet sites, where there are indecent pictures). The couple should also behave modestly, it is especially important for the woman to wear modest clothes and they should try to be modest during relations.
After several years of marriage, if there are still no children it is necessary to ask the advice of doctors. When the doctors offer doing different kinds of analyses and treatments, it is necessary to consult a Rabbi for not all of the treatments are permitted. Each time when the person is undergoing treatment, he should pray: "YEHI RATZON MILFANEKHA, ADONOY ELOHAY VE-ELOHEY AVOSAY SHEYEHE ESEK ZE LEREFUA SHLEMA VETIRPAENU VENIFKOD BEZERA KHAYA VEKAYAMA KI ROFE KHINAM ATA" - "May it be Your will, my God and the God of my fathers that this treatment will bring me full recovery. Cure me so that I will have healthy children because You treat graciously even those who are not deserving".