A Commentary, Critical, Practical, and Explanatory on the Old and New Testaments, by Robert Jamieson, A.R. Fausset and David Brown  at sacred-texts.com
psa 40:1In this Psalm a celebration of God's deliverance is followed by a profession of devotion to His service. Then follows a prayer for relief from imminent dangers, involving the overthrow of enemies and the rejoicing of sympathizing friends. In Heb 10:5, &c., Paul quotes Psa 40:6-8 as the words of Christ, offering Himself as a better sacrifice. Some suppose Paul thus accommodated David's words to express Christ's sentiments. But the value of his quotation would be thus destroyed, as it would have no force in his argument, unless regarded by his readers as the original sense of the passage in the Old Testament. Others suppose the Psalm describes David's feelings in suffering and joy; but the language quoted by Paul, in the sense given by him, could not apply to David in any of his relations, for as a type the language is not adapted to describe any event or condition of David's career, and as an individual representing the pious generally, neither he nor they could properly use it (see on Psa 40:7, below). The Psalm must be taken then, as the sixteenth, to express the feelings of Christ's human nature. The difficulties pertinent to this view will be considered as they occur. (Psa. 40:1-17)
The figures for deep distress are illustrated in Jeremiah's history (Jer 38:6-12). Patience and trust manifested in distress, deliverance in answer to prayer, and the blessed effect of it in eliciting praise from God's true worshippers, teach us that Christ's suffering is our example, and His deliverance our encouragement (Heb 5:7-8; Heb 12:3; Pe1 4:12-16).
inclined--(the ear, Psa 17:6), as if to catch the faintest sigh.
psa 40:3a new song--(See on Psa 33:3).
fear, and . . . trust--revere with love and faith.
psa 40:4Blessed-- (Psa 1:1; Psa 2:12).
respecteth--literally, "turns towards," as an object of confidence.
turn aside--from true God and His law to falsehood in worship and conduct.
psa 40:5be reckoned up in order--(compare Psa 5:3; Psa 33:14; Isa 44:7), too many to be set forth regularly. This is but one instance of many. The use of the plural accords with the union of Christ and His people. In suffering and triumph, they are one with Him.
psa 40:6In Paul's view this passage has more meaning than the mere expression of grateful devotion to God's service. He represents Christ as declaring that the sacrifices, whether vegetable or animal, general or special expiatory offerings, would not avail to meet the demands of God's law, and that He had come to render the required satisfaction, which he states was effected by "the offering of the body of Christ" [Heb 10:10], for that is the "will of God" which Christ came to fulfil or do, in order to effect man's redemption. We thus see that the contrast to the unsatisfactory character assigned the Old Testament offerings in Psa 40:6 is found in the compliance with God's law (compare Psa 40:7-8). Of course, as Paul and other New Testament writers explain Christ's work, it consisted in more than being made under the law or obeying its precepts. It required an "obedience unto death" [Phi 2:8], and that is the compliance here chiefly intended, and which makes the contrast with Psa 40:6 clear.
mine ears hast thou opened--Whether allusion is made to the custom of boring a servant's ear, in token of voluntary and perpetual enslavement (Exo 21:6), or that the opening of the ear, as in Isa 48:8; Isa 50:5 (though by a different word in Hebrew) denotes obedience by the common figure of hearing for obeying, it is evident that the clause is designed to express a devotion to God's will as avowed more fully in Psa 40:8, and already explained. Paul, however, uses the words, "a body hast thou prepared me" [Heb 10:5], which are found in the Septuagint in the place of the words, "mine ears hast thou opened." He does not lay any stress on this clause, and his argument is complete without it. It is, perhaps, to be regarded rather as an interpretation or free translation by the Septuagint, than either an addition or attempt at verbal translation. The Septuagint translators may have had reference to Christ's vicarious sufferings as taught in other Scriptures, as in Isa 53:4-11; at all events, the sense is substantially the same, as a body was essential to the required obedience (compare Rom 7:4; Pe1 2:24).
psa 40:7Then--in such case, without necessarily referring to order of time.
Lo, I come--I am prepared to do, &c.
in the volume of the book--roll of the book. Such rolls, resembling maps, are still used in the synagogues.
written of me--or on me, prescribed to me (Kg2 22:13). The first is the sense adopted by Paul. In either case, the Pentateuch, or law of Moses, is meant, and while it contains much respecting Christ directly, as Gen 3:15; Gen 49:10; Deu 18:15, and, indirectly, in the Levitical ritual, there is nowhere any allusion to David.
psa 40:9I have preached--literally, "announced good tidings." Christ's prophetical office is taught. He "preached" the great truths of God's government of sinners.
psa 40:11may be rendered as an assertion, that God will not withhold (Psa 16:1).
psa 40:12evils--inflicted by others.
iniquities--or penal afflictions, and sometimes calamities in the wide sense. This meaning of the word is very common (Psa 31:11; Psa 38:4; compare Gen 4:13, Cain's punishment; Gen 19:15, that of Sodom; Sa1 28:10, of the witch of En-dor; also Sa2 16:12; Job 19:29; Isa 5:18; Isa 53:11). This meaning of the word is also favored by the clause, "taken hold of me," which follows, which can be said appropriately of sufferings, but not of sins (compare Job 27:20; Psa 69:24). Thus, the difficulties in referring this Psalm to Christ, arising from the usual reading of this verse, are removed. Of the terrible afflictions, or sufferings, alluded to and endured for us, compare Luk 22:39-44, and the narrative of the scenes of Calvary.
my heart faileth me-- (Mat 26:38), "My soul is exceeding sorrowful, even unto death."
cannot look up--literally, "I cannot see," not denoting the depression of conscious guilt, as Luk 18:13, but exhaustion from suffering, as dimness of eyes (compare Psa 6:7; Psa 13:3; Psa 38:10). The whole context thus sustains the sense assigned to iniquities.
psa 40:13(Compare Psa 22:19).
psa 40:14The language is not necessarily imprecatory, but rather a confident expectation (Psa 5:11), though the former sense is not inconsistent with Christ's prayer for the forgiveness of His murderers, inasmuch as their confusion and shame might be the very means to prepare them for humbly seeking forgiveness (compare Act 2:37).
psa 40:15for a reward--literally, "in consequence of."
Aha--(Compare Psa 35:21, Psa 35:25).
psa 40:16(Compare Psa 35:27).
love thy salvation--delight in its bestowal on others as well as themselves.
psa 40:17A summary of his condition and hopes.
thinketh upon--or provides for me. "He was heard," "when he had offered up prayers and supplications with strong crying and tears, unto Him that was able to save him from death" [Heb 5:7].