[Another interpretation: "When a woman emits seed and bears a male" (Leviticus 12:2).] If the woman comes first, she bears a male; if the man comes first, she bears a female. Rabbi Abin the Levite, son of Rabbi, said: Scripture hinted to you, "If she bears a female" (Leviticus 12:5) — if the man comes first, she bears a female; if the woman comes first, she bears a male, as it is said, "When a woman emits seed and bears a male." Rabbi Chiyya bar Abba said: Therefore the male is attributed to the woman, and the female to the man, as it is said, "Behold, Milcah, she also has borne children to your brother Nahor: Uz his firstborn, and Buz his brother" (Genesis 22:20-21), "and Bethuel begot Rebekah" (Genesis 22:23); and so it says, "Maacah, Caleb's concubine, bore Sheber and Tirhanah. She also bore Shaaph the father of Madmannah, Sheva the father of Machbenah and the father of Gibea; and the daughter of Caleb was Achsah" (I Chronicles 2:48-49). Behold, the females were attributed to the man and the males to the woman; therefore it is said, "When a woman emits seed." Rabbi Aybu said: The Holy One, blessed be He, performs acts of wonder with this human being. A person who is placed in a furnace for a single day — does his soul not convulse upon him? Yet that infant is placed in his mother's belly for nine months, and the Holy One, blessed be He, guards him. Our Rabbis said: The Holy One, blessed be He, performed acts of wonder with this human being. A person who is placed in a bath for a single day — his soul is distressed upon him; yet the infant is placed in his mother's belly for nine months and his soul is not distressed upon him. [Why? Because the Holy One, blessed be He, performs acts of wonder with him.] Job said, "I will fetch my knowledge from afar" (Job 36:3). For Job would see human beings — a woman giving birth to a man, and the ship floating upon the waters finger by finger — and he was astonished at these matters, and said, "I will fetch my knowledge from afar." Therefore it is written, "When a woman emits seed."
Why the Womb Is a Miracle in Tanchuma on Tazria
Midrash Tanchuma Buber, Tazria 4:1
[ד"א אשה כי תזריע וילדה זכר]. אם קדמה האשה יולדת זכר, אם קדם האיש (מוליד) [יולדת- נקבה. אמר ר' אבין הלוי [ברבי] רמז לך הכתוב אם נקבה תלד, אם קדם האיש מולדת נקבה, קודמת האשה מולדת זכר, שנאמר אשה כי תזריע וילדה זכר. אמר ר' חייא בר אבא לפיכך הזכר נתלה באשה, והנקבה באיש, שנאמר הנה ילדה מלכה גם היא בנים לנחור אחיך את עוץ בכורו ואת בוז אחיו (בראשית כב כ כא), ובתואל ילד את רבקה (שם שם כג), וכן הוא אומר פלגש כלב (ילדה) [מעכה ילד] (שכר) [שבר] ואת תרחנה. ותלד (שצף) [שעף] אבי מדמנה, (ואת) [את] שוא אבי מכבנא ואבי (גבעה) [גבעא] ובת [כלב] עכסה (דה"א ב מח מט), הוי נתלו הנקבות באיש והזכרים באשה, לכך נאמר אשה כי תזריע. אמר ר' אייבו מעשה נסים הקב"ה עושה עם האיש הזה, אדם שהוא נתון בקמון יום אחד, אין נפשו מפרכסת עליו, אבל התינוק ההוא נתון במעי אמו תשעה חדשים והקב"ה משמרו, רבותינו אמרו מעשה נסים הקב"ה עשה עם האדם הזה, האדם שהוא נתון באמבטי יום אחד נפשו מקנטת עליו, והתינוק נתון במעי אמו ט' חדשים ואין נפשו קניטה עליו, [למה שהקב"ה עושה עמו מעשה נסים]. אמר איוב אשא דעי למרחוק (איוב לו ג), והיה איוב ראה בני אדם אשה יולדת איש, והספינה שטה בתוך המים אצבע על אצבע, ותמה על הדברים האלו, ואומר אשא דעי למרחוק, לכך כתיב אשה כי תזריע.