PROPER TIMES FOR BI'AH [Bi'ah: time]
Gemara
(R. Chama bar Chanina): "That she bore to Levi in Mitzrayim" - Yocheved was born in Mitzrayim, but not conceived there. She was conceived on the descent to Mitzrayim, and was born between the walls (the entrance to Mitzrayim).
Ta'anis 11a (Reish Lakish): It is forbidden to have Bi'ah in famine years - "two sons were born to Yosef before the famine years."
(Beraisa): People lacking children may have Bi'ah in famine years.
Nedarim 20b: Eima Shalom said that her children were exceedingly beautiful because her husband (R. Eliezer) did not have relations with her at the beginning or end of the night, only at midnight.
I asked him why. He said that it is lest he think about other women, which would make the children like Mamzerim.
Berachos 5b (Beraisa - Aba Binyamin): I always exerted myself that my bed should be north-south.
Rishonim
The Rif and Rosh (Ta'anis 2b and 1:8) bring the Gemara verbatim.
Question: Yocheved was conceived during the descent to Mitzrayim, which was during the famine!
Answer #1 Ran (DH Asur): The Isur is because Yisraelim are in pain. During the descent, Yisrael knew that they and Yosef had ample food. Yosef refrained because he thought that his family was in pain.
Answer #2 (Beis Yosef OC 575 DH v'Ha): Bnei Yisrael descended right after Yosef revealed himself. Seven or nine months earlier, they did not know that Yosef was alive! It seems that there was no Isur before Matan Torah. The verse from Yosef is a mere Asmachta. In any case he was permitted before his second son was born!
Bach (DH v'Asur): If it were permitted to people with children, there would be no Midas Chasidus for someone without children to be stringent.
Answer #3 (Tosfos Ta'anis 11a DH Asur): There is no Isur. It is optional Midas Chasidus. Yosef wanted to be stringent; Levi did not.
Rebuttal (Korban Nesanel 50): Reish Lakish said 'Asur'. This is not optional!
Answer (Taz OC 574:2): The Gemara did not permit 'one who did not fulfill Peru u'Rvu', rather, 'people lacking children', i.e. without any children, for this greatly pains a person. Before Matan Torah, only the seven Mitzvos were obligatory. Since the Torah alluded to the Isur, we say that it is forbidden after Matan Torah. I say that there is no Midas Chasidus for someone without children to Mevatel the great Mitzvah of Peru u'Rvu.
Answer #4 (Mizrachi Bereishis 41:50): Levi did not have a daughter yet, so he had not yet fulfilled Peru u'Rvu, so he was permitted.
Question (Beis Yosef, ibid.): If so, also Yosef was permitted!
Answer #1 (Korban Nesanel 50): He was permitted. He chose to be stringent.
Answer #2 (Kaf ha'Chayim 574:13): Perhaps Yosef knew through Ru'ach ha'Kodesh or his Chachmah that he would not have a daughter. Alternatively, he held like Beis Shamai that one fulfills Peru u'Rvu with two sons.
Ran (DH Chasuchei): The Heter for 'someone lacking children' is for one who has not fulfilled Peru u'Rvu.
Rambam (Hilchos Ta'anis 3:8): If Yisrael were fasting due to lack of rain and were not answered... we diminish Kidushin and Nisu'in, unless one did not fulfill Peru u'Rvu. Bi'ah is forbidden to one who fulfilled Peru u'Rvu.
Rambam (Hilchos De'os 5:4): It is not proper for a Chacham to have relations in the beginning of the night when he is satiated, nor at the end of the night when he is hungry, rather, in the middle of the night.
Ramban (Igeres ha'Kodesh Perek 3): Aba Binyamin exerted himself that his bed should be between north and south. One who does so merits to have sons, and his wife will not miscarry. This refers to having relations at the intermediate time, between the extremes of north (cold, i.e. hunger, at the end of the night) and south (heat, i.e. satiation, shortly after eating).
Rambam (Hilchos Isurei Bi'ah 21:10): It is the way of Kedushah to have Bi'ah only in the middle of the night.
Poskim
Shulchan Aruch (OC 240:7): One should not have Bi'ah at the beginning or end of the night, lest he hear other people. Rather, he should have Bi'ah in the middle of the night.
Magen Avraham (20): This is only for very pious people, or for one who is concerned lest he think about another woman. The Kabalah says great secrets about why Bi'ah should be after midnight, but Heaven forbid to come to Zera l'Vatalah due to delaying for this.
Kaf ha'Chayim (2): A Chacham should have Bi'ah after midnight, and only on Shabbos or Yom Tov, for this is when new Neshamos are given. Before midnight is like a weekday. The night of her Tevilah is also permitted. One who might come to lustful thoughts should not be stringent, especially at times when she cannot become pregnant.
Shulchan Aruch (240:12): In famine years it is forbidden to have Bi'ah, except for Chasuchei Banim (someone without children).
Mishnah Berurah (47): This refers to one who has not fulfilled Peru u'Rvu. Even if he has sons but no daughter, he is permitted.
Rema: The same applies to other afflictions that are like famine.
Kaf ha'Chayim (85): This refers to afflictions that deplete food, e.g. locusts, but not to pestilence. Keneses ha'Gedolah says that some include all afflictions, but we rely on the Bavli which mentioned only famine.
Shulchan Aruch (574:4): In famine years it is forbidden to have Bi'ah, except for the night she immerses and people lacking children.
Source (Beis Yosef DH Garsinan): In the Yerushalmi (Sof Halachah 6), R. Yehudah permits Ta'evi (people who desire) children. R. Yosi says, only the night of Tevilah. It seems that he does not refers to Ta'evi Banim, for they may have Bi'ah until they know that she is pregnant. Rather, he refers to the Isur to everyone, and permits the night of Tevilah.
Rebuttal (Magen Avraham 5): If R. Yosi refers to the Isur, why did he say 'only the night of Tevilah'? He should have said 'except for'! Why did Tosfos and others struggle to find a Heter for Levi? Perhaps Yocheved was conceived on the night of Tevilah! Rather, R. Yosi permits Ta'evi Banim only the night of Tevilah, for he holds that a woman gets pregnant right after Tevilah. The Gemara and Poskim permit childless people at all times. There is no source to permit Leil Tevilah (to others). No Poskim bring this Heter.
Beis Yehudah (40): If the price of food doubled, it is forbidden, even if he has food in his house.
Sha'arei Teshuvah (1): Keneses ha'Gedolah says that nowadays we rely on Tosfos, who says that it is only Midas Chasidus. If food is available but expensive, even if it is twice the price, this is not called famine. The Taz here contradicts what he wrote in Divrei David (Bereishis 41:50), that only Bi'ah for pleasure is forbidden, but not for the sake of children or one overcome by desire who might have an emission if he refrains. This is included in the Heter for childless people. It is not clear how we uproot the Mitzvah mid'Oraisa of Onah (Bi'ah at regular times). We do not scorn one who rules leniently regarding the night of Tevilah, against the Magen Avraham.
Mishnah Berurah (11): It seems that one may rely on the lenient opinions for the night of Tevilah, especially regarding afflictions other than famine.
Mishnah Berurah (12): If one has children who desecrate Shabbos and desires Kosher children, he is like one without children.