Which women suffer the pains of childbirth?
(12,2) “Speak to the children of Yisrael, saying: If a woman conceives and gives birth to a male, she shall be unclean for seven days. As the days of her menstrual flow (דותה) she shall be unclean.”
Rashi explains that the word דותה is an expression of something which flows from her body. Alternatively, it is an expression of sickness, because a woman does not menstruate without feeling ill, her head and her limbs becoming heavy for her.
It is possible to explain that both explanations are true, because the curse with which Chavah (Eve) was cursed - "I shall surely increase your sorrow and your pregnancy; in pain you shall bear children" - refers to the blood of menstuation and the blood of virginity. And we know that righteous women were not included in this curse and so do not suffer the pains of menstruation and of childbirth. Only those women who are immodest suffer these things.
Therefore, the first explanation of Rashi, that it is an expression of something which flows from the body, meaning without any distress, refers to righteous women. And the second explanation, that it is an expression of sickness, refers to women who do not conduct themselves with modesty.
Why does a woman need to bring an offering after childbirth?
(12,6) “And on the completion of the days of her purification, whether for a son or for a daughter, she shall bring a sheep in its first year as a burnt offering, and a young dove or a turtle dove as a sin offering, to the entrance of the Tent of Meeting, to the Kohen.”
The gemora in Niddah 31 writes that the students of R. Shimon bar Yochai asked him: Why did the Torah say that a women who has given birth must bring an offering. He said to them: When she kneels to give birth she swears impestuously that she will no longer sleep with her husband (so that she will never again suffer the pain of childbirth).
The question that needs to be asked on this gemora, is why did the students specifically ask R. Shimon this question? Also, why did he answer that she is impestuous in her swearing, which implies that she swore earlier than might have been normal?
We can answer these questions with the gemora in Niddah 40a, which says that a woman who gives birth by a caesarian section does not need to count the days of impurity and purity that normally follow a birth, nor does she need to bring an offering. But R. Shimon says this is a valid birth, and thus she must bring an offering.
Now, the Rambam writes in his commentary on Mishnah 8:2 of Bechoros, that after a birth by caesarian section a woman can no longer become pregnant. According to this we can explain that the students knew very well that the reason why the woman brings an offering is because she swore that she would no longer sleep with her husband. But R, Shimon must have had a different reason, because he holds that a woman who gave birth by way of a caesarian section also brings an offering, and yet she would have no reason to swear not to be with her husband again since she will no longer give birth! For this reason they specifically asked R. Shimon this question.
And therefore R. Shimon answered that at the time that she kneels to give birth she swears impestuously. That is, before she even knows whether she will give birth naturally or not, she precedes to swear that she will no longer sleep with her husband, and therefore she needs to bring an offering. With this all our questions are answered perfectly.