Here Paul is not referring to the rightful obedience to Mosaic law in current times which is by faith in Christ, as argued in Rom 3:31. Here in 1Tim 1, the passage warns against false teachers of the law, who introduced vain controversies and myths related to Jewish customs or teachings. After warning against such heresies, Paul reminds us the goodness of law, that it is harmless if we don't violate it. The violations comprises the general sins listed. The meaning of Law here is general or moral law rather than covenantal law of Moses, as Gary Everett points out:
The Meaning of the Word “Law” – When Paul uses the word “law” in 1Ti
1:8-11 he may not be using the word entirely in the narrow sense to
refer strictly to the Mosaic Law. He certainly has to mean the Jewish
Old Testament because this was the only Scriptures that the early
Church upheld until the writing of the New Testament books, but we
should allow the word “law” to carry a broader application to include
not only the Mosaic Law, but “civil law and order,” or “governmental
rule over a society” as well, since he is establishing order in a
largely Gentile church. Thus, Paul is saying that just as God has
established law and order over societies (1Ti 1:8-10), so does God
establish law and order over His Church. It is sound doctrine that is
the basis for this Church order (1Ti 1:10). Sound doctrine establishes
order in the Church in the same way that civil law establishes order
in a society. It was Paul who was given the divine commission to write
this sound doctrine contained within the Church Epistles as he
fulfilled his commission to take the Gospel of Jesus Christ to the
Gentile nations. [Everett's Study Notes on the Holy Scriptures]
What is lawful according to Paul is to adhere strictly within the sound doctrines of the Gospel, as taught by him (or other apostles of the Church).
Mark Dunagan commentary states:
1Tim 1:11 “According to the glorious gospel”: In the Greek the last phrase
is literally “the sound doctrine”, which means that “sound teaching”
is another name for the gospel message. This also means that there is
not any difference between what composes the gospel and what composes
sound doctrine, they are one and the same. Therefore, the gospel
contains God’s standard of morality as well as what one must do to be
saved. Those who contend for a distinction between “doctrine” and
“gospel” are not using the Scriptures lawfully. Paul is saying that
this view of the Law and its purpose and what is not lawful is given
according to the teaching found in the glorious gospel. Thus this
estimate of the Law was not Paul’s own opinion, but part of the
glorious gospel that Paul was commissioned to preach