When an Israelite woman gave birth to a male child, the Lord said to Moses that this was to be done,
“Speak to the children of Israel, saying: ‘If a woman has conceived, and borne a male child, then she shall be unclean seven days; as in the days of her customary impurity she shall be unclean'” (Leviticus 12.2).
It does not appear to me as to why this seven days of uncleanness existed, but it is what the Lord decreed.
Also, this should not be thought of as sin. Sometimes uncleanness equals sin, and sometimes it does not. In this case, it does not.
Leviticus 12.4 showed what her uncleanness meant,
“She shall then continue in the blood of her purification thirty-three days. She shall not touch any hallowed thing, nor come into the sanctuary until the days of her purification are fulfilled” (Leviticus 12.4).
That was what the Lord said to do, and so faithful Israelite mothers observed it.