All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
This case bears two possibilities: that the wife stipulated having children in any case or that she stipulated that he should utilize the available means and seek treatment to have children. If she has stipulated having children in any case, it is regarded as an invalid condition since she is stipulating what is not within the human being’s control or power. If she has stipulated that he should utilize the available means and seek treatment to have children, then it is a valid condition that does not contradict the very purposes of marriage in Islam; rather, it is one of the main purposes of marriage in Islam. Ma‘qil ibn Yasaar reported that the Prophet, sallallaahu ‘alayhi wa sallam, said: “Marry the loving and prolific woman; for I will outnumber the nations by you.”
In another wording of the same narration, the Prophet, sallallaahu ‘alayhi wa sallam, said: “I will boast of your large numbers in front of other nations (on the Day of Judgment).” [Abu Daawood, An-Nasaa’i and Ahmad]
Usaamah ibn Shareek narrated that the Prophet, sallallaahu ‘alayhi wa sallam, said: “Seek treatment for there is no disease that Allaah The Almighty has created except that He also has created its treatment except one single disease: old age." [Abu Daawood and At-Tirmithi]
Hence, it is an obligation on this husband, and one of his wife’s rights over him, to undergo the necessary medical examinations and the due treatments to the best of his abilities. If he does so and they do not have children, then it is not incumbent on him to do anything further. However, if he insists on his refusal to undergo treatment, the wife has the right to seek divorce.
Allaah Knows best.