Luke 2.21-40 captures many key themes of Luke, such as the role of the Holy Spirit in the earthly life of Jesus Christ, God's uplifting of the poor, and models of Christian devotion/discipleship. One of those themes is Christ's obedience to the law. The observance of the law on behalf of Jesus is referred to six times in this passage (vv. 21, 22, 23, 24, 27, 39). Robert Stein, in his commentary on Luke (NAC) states that this is Luke's way of saying that the law is still relevant and pressing on the believer's life, a guide for conduct. Thus these duties carried out on Jesus' behalf become an example for the disciples of Christ.
The problem with this interpretation is that each of the laws fulfilled are ceremonial - circumcision on the eighth day (21); purification (22); redemption (23-24, 27, 39) - not moral. Clearly, Luke would not have Theophilus following Mary and Joseph's example in order to be a disciple of Christ. Luke, after all, is the one who records the decision of the Jerusalem Council regarding circumcision and other ceremonial stipulations being imposed on the Gentile churches: "For it has seemed good to the Holy Spirit and to us to lay on you no greater burden that these requirements: that you abstain from what has been sacrificed to idols, and from blood, and from what has been strangled, and from sexual immorality. If you keep yourselves from these, you will do well" (Acts 15.28-29).
Stein might argue that it is not the ceremonial aspects of the law, but the law as the command of the Lord that Jesus' parents follow and thus become exemplary. This would be one way of avoiding the contradiction between his interpretation and the clear teaching of Acts, Galatians, Colossians, Hebrews and the NT in general regarding the ceremonial aspects of the law.
But it may be that Luke had a very different purpose in recording their obedience to the law in these particulars; namely, to illustrate that Christ was born under the law. Even when His fulfillment of the law was in another's hands, God saw that He fulfilled it.
But when the fulness of time had come, God sent forth his Son, born of a woman, born under the law, to redeem those who were under the law, so that we might receive the adoption as sons. And because you are sons, God has sent the Spirit of his Son into our hearts, crying "Abba! Father!" so you are no longer a slave, but a son, and if a son, then an heir through God.
Another thought: Isn't it interesting that the first-born son was to be redeemed by a sacrifice because every first-born male belonged to God. Thus every first-born animal was to be sacrificed to God or its neck was to be broken, but every first-born man was to be redeemed. Jesus was redeemed by payment to the sanctuary (Luke 2.23; cf. Exod 13.2, 12-13; Num 18.15-17), but He would later be sacrificed for the redemption of covenant-breaking, lawless sinners.