Answer: That we may know the holy nature and will of God, and the sinful nature and disobedience of our hearts; and thus our need of a Savior. The law also teaches and exhorts us to live a life worthy of our Savior.
Scripture: Romans 3:20 For by works of the law no human being will be justified in his sight, since through the law comes knowledge of sin.
Source: New City Catechism