In pronouncing the law “good” (v.8) Paul is teaching Timothy how to deal with those who desire to teach it (v.7). You start by acknowledging the law is as good as Moses said (Deut.4:6-8) and can do good things (Ps. 19:7,8; 119: 98). Even the man who says we are not under law (Rom.6: 15) keeps insisting the law is good (v.8cf.Rom.7:12).
But the law is good only “if” it is used lawfully (v.8). It is not made for righteous men, i.e., it’s not for saved men. Only saved men are righteous. Remember, only the righteous saved in Israel will inherit the land for ever (Ps.37:29), and only the righteous have eternal life (Mt.25: 46). None of us are righteous in ourselves (Rom.3:10), but we can be “made righteous” by the obedience of Christ (Rom.5:19).
Since there are only two kinds of people in the world, saved and unsaved, and the law isn’t made for the saved, it must be made for the unsaved, a group Paul calls “the lawless.” He also calls them “the disobedient” (v.9). Peter contrasts “disobedient” people to believers (IPe.2:7) because they “obey not the gospel” (IIThes.1:8).
God made the law for the unsaved to show them they are sinners (Rom.3:20) who need a Savior. When the Law finds its way to a “good” moral person, it makes the sin in them “exceeding sinful” (Rom.7:13). When we’re told not to do something, our fallen nature wants to do it all the more. That’s why Paul says that “the strength of sin is the law” (ICor.15:56).
Since the first commandment is not to have other gods before God, if you do, you are “ungodly” (v.9cf.Ex.20:3). Those who make graven images (Ex.20:4) are “sinners” (v.9). Since the next commandment says to keep the Sabbath “holy” (Ex.20:8), if the Jews who were under the law didn’t keep it holy, they were “unholy” (v.9). Since we’re not supposed to take God’s name in vain (Ex.20:7), the “profane” are those who break this commandment (v.9). When Paul says the law was made for “murderers,” he’s addressing Exodus 20:13. When he adds you shouldn’t kill your mother or father, he’s referencing Exodus 20:12.
Under the law “manslayers” (v.9) were those who killed people unintentionally, but in this context the word refers to those who kill anyone, not just fathers and mothers. God left the commandment “thou shalt not kill” open-ended to include even the killing of yourself in suicide. And if you don’t believe that this open-ended commandment prohibits abortion, you are guilty of age discrimination, for you are saying that it is okay to kill the old but not the young.
A whore in our day and age is a prostitute who has sex for money, so a “whoremonger” (v.10) would be a prostitute’s customer. But originally a whore was any promiscuous woman, so a whoremonger was any promiscuous man or woman, any who violate Exodus 20:14. Paul is also referencing the commandment not to covet (Ex.20:17), since coveting is what causes whoremongering (Rom.7:7). Whoremongering also covers them that defile themselves with mankind (v.10), for adultery with “mankind” is no better than adultery with a woman (cf.Lev.18:22).
The law was also made for “menstealers” (v.10), those who’d violate Exodus 20:15 by stealing the most valuable thing that can be stolen, people. “Liars” (v.10) break the commandment found in Exodus 20:16. We think of courtrooms when we think of “perjured persons,” but that’s only because perjury means lying under oath.
When Paul adds, “if there be any other thing that is contrary to sound doctrine” (v.10) according to his gospel (v.11), the Sabbath was contrary to sound doctrine according to the law, but not according to Paul’s gospel (Col.2:16). So if you use that law to bring a knowledge of sin on an unbeliever you are using it unlawfully.
Paul calls his gospel “glorious” to remind Timothy to remind those that desired to be teachers of the law that his gospel wasn’t contrary to the law as he’d been charged (Acts 18:13), it was a secret, unrevealed part of the new covenant, God’s glorious solution to the weakness and unprofitableness of the law (IICor.3:5-10).