Good quote by Calvin on how to understand David’s extolling of God’s law and Paul’s speaking of the death the law brings:
It is certain, that if the Spirit of Christ does not quicken the law, the law is not only unprofitable, but also deadly to its disciples. Without Christ there is in the law nothing but inexorable rigour, which adjudges all mankind to the wrath and curse of God. And farther, without Christ, there remains within us a rebelliousness of the flesh, which kindles in our hearts a hatred of God and of his law, and from this proceed the distressing bondage and awful terror of which the Apostle speaks. These different ways in which the law may be viewed, easily show us the manner of reconciling these passages of Paul and David, which seem at first view to be at variance. The design of Paul is to show what the law can do for us when, without the promise of grace, it strictly and rigorously exacts from us the duty which we owe to God; but David, in praising it as he here does, speaks of the whole doctrine of the law, which includes also the gospel, and, therefore, under the law he comprehends Christ.
John Calvin, Commentary on the Psalms (Psalm XIX)