Why did God give us the law in the Old Testament? And is it still relevant today? 
I used to think that in the Old Testament, the laws were given to the people to measure whether they would be accepted by God or not. Those who kept the law would be accepted (or saved) by God and those who didn’t would not be accepted. In the New Testament, we are judged entirely differently – by our faith. But in the Old Testament, we were judged by our our good works. 
By that reason of thinking, I thought that the people in the Old Testament were saved by keeping the law, which obviously changed in the New Testament. But further reading and studying the scripture, I realized I was wrong. Even in the Old Testament, the people were saved by faith. (Take Abraham for example. How did he become saved? By faith! The law didn’t even exist during Abraham’s time!) 
But then, why did God give Israelites the law? If not to assess them by it and save them (if they pass the test), then why? It was so that it would go well with them – that they would have a happier life. 
“And you shall do what is right and good in the sight of the Lord, that it may go well with you, and that you may go in and take possession of the good land that the Lord swore to give to your father.” Deuteronomy 6:18It’s the same reason that I instruct my children. I don’t give them rules so that by obeying them, they will become my children. I give them rules BECAUSE they are my children and I want things to go well with them! 
So then, are the Old Testament laws still relevant today? Yes. At least the moral laws such as the 10 commandments. However, we obey them not in order to belong to God, but because we came to belong to Him through faith and in order for things to go well for us. 
Obey the 6th commandment (Thou shall not commit adultery) and you will be happier, for example!
PH