Continuing in Romans 7, now that he has said we died to the law, he has to give an explanation because many would feel this is attacking the law. The problem is not the law, but us. So he goes on to defend the law, and why God did this:
7 What shall we say, then? Is the law sinful? Certainly not! Nevertheless, I would not have known what sin was had it not been for the law. For I would not have known what coveting really was if the law had not said, “You shall not covet.”
So he first notes that the law is not sin. In fact the law points out sin. This goes back to what he said in Chapter 3. From Romans 1:18 - 3:20 Paul is spelling out how the whole world is alike under sin. This culminates in the following:
19 Now we know that whatever the law says, it says to those who are under the law, so that every mouth may be silenced and the whole world held accountable to God.
20 Therefore no one will be declared righteous in God’s sight by the works of the law; rather, through the law we become conscious of our sin.
The law cannot declare us righteous because we are all alike under sin. He then from 3:21-the end of chapter 5 spells out that righteousness is by faith, not from the law.
So the law points out sin, and points out what we should do. It is righteous. But it cannot make us righteous. That is because in our weakness of our sinful flesh we cannot keep it.
8 But sin, seizing the opportunity afforded by the commandment, produced in me every kind of coveting. For apart from the law, sin was dead. 9 Once I was alive apart from the law; but when the commandment came, sin sprang to life and I died. 10 I found that the very commandment that was intended to bring life actually brought death. 11 For sin, seizing the opportunity afforded by the commandment, deceived me, and through the commandment put me to death. 12 So then, the law is holy, and the commandment is holy, righteous and good.
Here he says the law intended to bring life brought death--because we couldn't keep it. The law says we should do it. We don't do it, resulting in death. This is not the fault of the law. The law is still holy, righteous and good.