That Psalm 40 is primarily a Messianic psalm speaking mainly about the work of Christ is evident from its quotation as such in Hebrews 10:5-10. The psalm is prophesying particularly of His incarnation, as He says: "Lo, I come: in the volume of the book it is written of me" (Psalm 40:7).
Burnt offerings and sin offerings had indeed been required from God's people under the law, but these were not an end in themselves. These sacrifices were meaningless unless they were offered out of a willing heart, obedient expressions of submission to a forgiving God.
That was the implication of the "opened ear," a symbolic expression indicating one's willingness thenceforth to hear only the voice of his master and to submit to His will in all things. If a freed bondservant "shall plainly say, I love my master . . . I will not go out free: Then his master shall . . . bore his ear through with an aul; and he shall serve him for ever" (Exodus 21:5-6). This was the testimony of the coming Messiah, as reported in our text.
Then note its application as recorded in Hebrews 10:5: "Wherefore when he cometh into the world, he saith, Sacrifice and offering thou wouldest not, but a body hast thou prepared me." That is, the phrase "mine ears hath thou opened" is translated by the Holy Spirit as "a body hast thou prepared me." The perfect submission of the Son to the Father required that He become a man, with a very special human body prepared by His Father. Then Psalm 40:7 becomes (in Hebrews 10:7): "Lo, I come . . . to do thy will, O God. . . . By the which will we are sanctified through the offering of the body of Jesus Christ once for all" (Hebrews 10:9-10). HMM http://www.icr.org/article/5958/