Religious purity rules dictated that Mary was unfit to meet God until 40 days after giving birth.
Giving birth was considered an unclean, messy process, hence Mary’s period of exclusion (and the period was 80 days if the baby was a girl!). And she must make a sacrifice on entering the temple. But God saw fit to be involved with the human birth of Jesus in a cowshed, as God is now always willing and able to be with us in every situation, however uncomfortable.
So far as we know, throughout his childhood Jesus’ family conformed to the religious rules of the time. These were based on the rules laid down by Leviticus and other books of the law. They included the requirement that every first-born male animal born should belong to God and so be sacrificed. But for human first-born sons – after Abraham’s attempt to sacrifice Isaac – this was amended to a ‘buy-back’ system where an animal sacrifice was deemed to be a sufficient substitute gift. Two animals were normally required and the minimum, for the poorest parents, was two pigeons or doves.
So this was what Joseph and Mary were involved in when Jesus was 40 days old. The boy baby was presented to God and the doves sacrificed. They, the family, could go back to a normal social life, having all been religiously unclean during those 40 days. In that time they were barred from all religious activity and association in the Temple or synagogue.
Still now, some people are not accepted in some places of worship and some religious ceremonies because they are deemed to be ‘unclean’ in some way because of their manner of life. But they are never outside the love of God as shown in Jesus.
We can also see that within the Temple (the religious institution par excellence of that time) God was also present and active in responding to the prayers of Simeon:
“For my eyes have seen your salvation,
which you have prepared in the sight of all nations:
a light for revelation for the Gentiles,
and the glory of your people, Israel”
Luke 2:30-32, NIV
and to the prayers of Anna:
“She gave thanks to God and spoke about the child to all who were looking forward to the redemption of Jerusalem.”
Luke 2:38, NIV
These messages point to the expectation of the messiah. Mary and Joseph fulfilled the religious rules, keeping the family on-side. Luke tells us then, that they took up their normal location again, providing Jesus a home in which he could grow and mature:
When Joseph and Mary had done everything required by the Law of the Lord, they returned to Galilee to their own town of Nazareth.
Luke 2:39, NIV