"And when the days of her purification are fulfilled, whether for a son or for a daughter, she shall bring a lamb in its first year for a burnt offering, etc." (Leviticus 12:6). Why does she bring an offering? Our Rabbis said: A hundred times she cries out at the hour when she sits upon the birthing stool, ninety-nine of them toward death and one toward life. And since the pangs come upon her, she vows that she will no longer be intimate with her husband. Therefore she brings an offering, as it is said: "She shall bring a lamb in its first year, etc."
Why the New Mother Brings a Lamb After Childbirth
Midrash Tanchuma Buber, Tazria 6:1
ובמלאת ימי טהרה לבן או לבת תביא כבש בן שנתו לעולה וגו' (ויקרא יב ו). למה היא מביאה קרבן, אמרו רבותינו מאה פעמים היא פועה בשעה שהיא יושבת על המשבר, תשעים ותשעה למיתה ואחד לחיים, וכיון שהצרות מגיעות אצלה, היא נודרת שאינה מכרת אישה עוד, לכך היא מביאה קרבן, שנאמר תביא כבש בן שנתו וגו'.