God gave His law in the Old Testament to show us what we are like.
According to the Apostle Paul, God’s law did three things for us (Romans 3:19-20). First, it left us without any excuse. God said do and we didn’t and God said don’t and we did. Second, it left us guilty before God; that is, obvious lawbreakers who’ve come miserably short of God’s standard of sinless perfection. Finally, it brought to us the knowledge of sin; that is, the knowledge that there is something horribly wrong with us, because no matter how hard we try to do right we keep doing wrong.

Notice, Paul taught that the Law brought to us the knowledge of sin, not sins. Our real problem is not our sins, what we do, but our sin, what we are. We’re not sinners because we sin. We sin because we’re sinners. A thief is not a thief because he steals, but he steals because he is a thief. A liar is not a liar because he lies, but he lies because he is a liar.

By bringing to us the knowledge of sin, God’s Law proved to us the impossibility of ever making ourselves acceptable to God by our obedience to his Law. Therefore, God’s Law prepared us for the coming of God’s Son, by proving to us our need of a Savior.