The Lord said to Moses, “Say to the Israelites: ‘A woman who becomes pregnant and gives birth to a son will be ceremonially unclean for seven days, just as she is unclean during her monthly period.
On the eighth day the boy is to be circumcised.
Then the woman must wait thirty-three days to be purified from her bleeding. She must not touch anything sacred or go to the sanctuary until the days of her purification are over.
“‘When the days of her purification for a son or daughter are over, she is to bring to the priest at the entrance to the tent of meeting a year-old lamb for a burnt offering and a young pigeon or a dove for a sin offering.
He shall offer them before the Lord to make atonement for her, and then she will be ceremonially clean from her flow of blood.
“‘These are the regulations for the woman who gives birth to a boy or a girl.
But if she cannot afford a lamb, she is to bring two doves or two young pigeons, one for a burnt offering and the other for a sin offering.
In this way the priest will make atonement for her, and she will be clean.’” (Leviticus 12)
Mary and Joseph carefully followed the Jewish law, setting the Lord Jesus Christ on a traditional path. They possibly didn’t grasp all that it meant, but they set him on the path as they understood it. (Note that they didn’t view the wisemen’s gifts as theirs, but presented Jesus at the temple with what they personally could afford.)