According to the Calvin’s classic formulation, God’s law has a threefold use (Institutes, II.vii.6-12).
These are helpfully summarised in the Reformation Study Bible:
Scripture shows that God intends His law to function in three ways, which Calvin crystallized in classic form for the church’s benefit as the law’s threefold use.
Its first function is to be a mirror reflecting to us both the perfect righteousness of God and our own sinfulness and shortcomings. As Augustine wrote, “the law bids us, as we try to fulfill its requirements, and become wearied in our weakness under it, to know how to ask the help of grace.” The law is meant to give knowledge of sin (Rom. 3:20; 4:15; 5:13; 7:7–11), and by showing us our need of pardon and our danger of damnation to lead us in repentance and faith to Christ (Gal. 3:19–24).
A second function, the “civil use,” is to restrain evil. Though the law cannot change the heart, it can to some extent inhibit lawlessness by its threats of judgment, especially when backed by a civil code that administers punishment for proven offenses (Deut. 13:6–11; 19:16–21; Rom. 13:3, 4). Thus it secures civil order, and serves to protect the righteous from the unjust.
Its third function is to guide the regenerate into the good works that God has planned for them (Eph. 2:10). The law tells God’s children what will please their heavenly Father. It could be called their family code. Christ was speaking of this third use of the law when He said that those who become His disciples must be taught to do all that He had commanded (Matt. 28:20), and that obedience to His commands will prove the reality of one’s love for Him (John 14:15). The Christian is free from the law as a system of salvation (Rom. 6:14; 7:4, 6; 1 Cor. 9:20; Gal. 2:15–19; 3:25), but is “under law toward Christ” as a rule of life (1 Cor. 9:21; Gal. 6:2).