For sin, taking occasion by the commandment, deceived me, and by it slew [me].
Note 5 at Ro 7:11: The ministry of the Law actually gave sin (the sin nature, see note 9 at Ro 5:21) an occasion against people. The corrupt rebellious nature of man will always lust for what it cannot have. Forbid people to do something that they were only mildly interested in before, and they will develop an uncontrollable lust for that very thing.
This is how the Law worked. Sin was already at work in man, but when the Law came, condemning their actions, sin came alive (Ro 7:9) in comparison to what it was before. The reason God did this was because mankind had been blinded to what sin was and its consequences. Sin had already beaten and enslaved people, but they didn't realize it. They thought they were good enough, until the Law came. Once they were forbidden to do and think certain ways, sin began to abound (Ro 5:20), and they became aware that they were, by nature, children of the devil (Eph 2:3) and needed a savior. That was the purpose and ministry of the Old Testament Law (see note 4 at Ro 3:19).
Failure to understand this truth has led many well-meaning religious people to attempt to get others to stop sinning through the proclamation of God's laws against, and punishments for, sin. That wasn't the purpose of the Law. According to these verses, sin actually revives and gains an occasion against people when the Law is used. The right use of the Law is to give knowledge of sin (Ro 3:20) and convince people that they are doomed without a savior. The Law is powerless to overcome sin. Only the grace of God can cause people to overcome sin (Ro 6:14).