Here is a good quote from Ursinus on the role of the law both before and after the preaching of the gospel:
The preaching of the law goes before, preparing and leading us to a knowledge of the gospel: “for by the law is the knowledge of sin.” (Rom. 3:20) Hence, there can be no sorrow for sin without the law. After the sinner has once been led to a knowledge of sin, then the preaching of the gospel follows, encouraging contrite hearts by the assurance of the mercy of God through Christ. Without the preaching there is no faith, and without faith there is no love to God, and hence no conversion to him. After the preaching of the gospel, the preaching of the law again follows, that it may be the rule of our thankfulness and of our life.
The law, therefore, precedes, and follows conversion. It precedes that it may lead to a knowledge and sorrow for sin: it follows that it may serve as a rule of life to the converted. It is for this reason that the prophets first charge sin upon the ungodly, threaten punishment, and exhort to repentance; then comfort and promise pardon and forgiveness; and lastly, again exhort and prescribe the duties of piety and godliness (Ursinus, Commentary, 472). HT: Ref21
Related post: Past, Present and Future Grace