Chasam Sofer (Vayikra 12:2): A woman who produces seed and gives birth to a boy. Rashi explains that if the woman produces seed first then she will have a boy... Also what is the reason that there is less spiritual impurity with the birth of a boy than for a girl? There is a need to examine this since the impurity of nida and birth resulted from the sin of the Tree of Knowledge which is obviously relevant only for women and not men. So why do males have the foreskin which is also from the sin of the Tree of Knowledge and not females? A possible answer is that the reason that the woman who gives seed first will give birth to a boy is because material from the woman and the man are intrinsically unique and distinct from each other. The nature of the male child is determined by the mother and that of the female by the father. Therefore when the woman gives seed first it is from the material that the woman received from the spiritual contamination resulting from the sin of the Tree of Knowledge which dominates the woman. It is from this impure material of the mother that the foreskin grows and therefore the male has the foreskin since the male is created from the material of the mother. This contribution of material by the mother has the consequence of reducing somewhat the mother’s spiritual contamination which resulted from the Tree of Knowledge. That is why after the birth of a male child she is spiritually impure for fewer days than after the birth of a female child. In contrast the material of a female child which comes from the father when he produces seed first does not contain any spiritual sickness from the Serpent and therefore the female child has no foreskin and thus the spiritual contamination resulting from the Tree of Knowledge is not reduced for the mother when she gives birth to a female child. That is why she is spiritually impure for twice as many days for giving birth to a girl than she is for a boy.