Rabbeinu Bechaye points out that three of the four matriarchs were barren. Only Leah was able to conceive easily.
One answer of Chazal is that Hashem has a longing for the prayers of Tzaddikim.
Rabbeinu Bechaye’s answer shows that there is a Divine plan in what transpired.
Had Sara not been barren, Avraham would not have married Hagar, Yishmael would not have come into the world. Hashem wanted there to be Yishmaelim.
Had Rivka not been barren for twenty years, Eisav would have been born sooner. Avraham would have had grief in seeing an evil grandson. He was promised that he would die peacefully, a happy man.
Had Rachel not been barren, Yakov would not have married Bilha and Zilpa, and the tribes of Gad and Asher, Dan and Naftali, would never have come into being.
We must always rely that Hashem knows best and we really cannot fathom His ways. We must faithfully submit ourselves to the Divine will.