Then when he says, but we know that the law is good, he describes the status of the law in regard to two things: first, as to the goodness of the law; second, as to the end and intention of the lawgiver, at knowing this.
He says, therefore: we know with certainty that the law is good and not evil, as some heretics claim: the law of the Lord is unspotted, converting souls (Ps 18:8); the law indeed is holy and the commandment holy, and just, and good (Rom 7:12). But it can happen that someone uses what is good in an evil manner. Therefore, since the law is good, it is required that a man use it... well. That is why he says, if a man use it lawfully. Otherwise it becomes deadly (Rom 8).
For there are in the law certain commandments that are moral and some that are ceremonial. The ceremonial laws have been given in figures to Christ and to the Church. But they need to be understood not only carnally but also spiritually, and as a figure of the truth to come; and it is important to know that they are not to be kept forever, but cease when the truth has appeared: I will make a new covenant with the house of Israel and with the house of Judah: not according to the covenant which I made with their fathers in the day that I took them by the hand to bring them out of the land of Egypt (Jer 31:31). That is the way a Gloss explains it.
But the Apostle seems to be speaking of the moral precepts, because he continues by saying that the law was made for sinners, and these are moral precepts. The proper use of these precepts is that a man not attribute more to them than is contained in them. For the law was given in order that sin be recognized: for I had not known concupiscence, if the law did not say: you shall not covet (Rom 7:7). Therefore, the hope of justification must not be placed in them, but in faith alone: we account a man to be justified by faith, without the works of the law (Rom 3:28).
Source: Commentary on 1 Timothy