The first verse of this passage immediately follows a verse in which Paul says that the purpose for sin causing his spiritual death through the Law was that he would understand it for what it really was. Therefore, it is natural to understand Paul as beginning this passage by introducing the first way in which the Law revealed the sinfulness of his sin to him: by the very nature of the Law and of his unregenerate state. The Law was spiritual, and is still spiritual. This means that it has to do with having fellowship with God. However, Paul, as he was having his sin revealed to him, belonged to the flesh, or the evil human nature, and had been sold into enslavement to sin. One way that he knew that he was a slave of sin was that he did not understand what he was doing, and he knew this because he was practicing what he hated.
In verse 16, we see the unsaved Paul attempt to reason with himself about his spiritual condition. He concludes that, since he is practicing what he hates, he agrees with what the Law says, and confesses that it is good. Therefore, he concludes that he must not be the one practicing sin, but the sin that lives in him is making him do it. Then, he continues to reason with himself by saying that he knows that nothing good lives in his evil human nature. The way that he knows this is that he is willing to do what the Law commands him to do, but he does not do it. The way that he knows this is that he does not do the good that he wants to do, but he is practicing the evil that he hates. Therefore, he concludes in verse 20 that he is not the one that is practicing sin, but his sin itself.
In verse 21, the unregenerate Paul draws an implication from his conclusion: he has evil in him, although he wants to do good. The reason that he knows this is that he delights in the Law, but he sees that his body is enslaved to sin, which makes him a prisoner of that enslavement. Therefore, he declares that he is a wretched man, and thinks about the possibility of someone setting him free from his spiritually dead body.
In verse 25, Paul includes a parenthesis, in which he, as his current self, declares that God deserves thanks through Jesus Christ. After he does this, he returns to speaking as his unregenerate self, and concludes that he is serving the Law with his mind, but he is serving sin with his body. In other words, he recognizes that the Law commands people to do good things, but he does not do what the Law commands him to do.