Because as the verse below states, the “works” (religious observances/ritualistic acts of the ‘Law’) will “not” justify anyone:
“because by the works of the Law no flesh will be justified in His sight; for through the Law comes the knowledge of sin.” (Romans 3:20)
Then, what does it do?
It keeps you away from “further unrighteousness” or from “more sinning acts” (note the phrase “through the Law” —-> “comes” —> “knowledge of sin” —> meaning it helps you determine ‘what’s sin or not’ to keep you away from ‘further unrighteousness’).
“Christ is the end of the law for righteousness to everyone who believes.” (Romans 10:4)
Christ —> “end of the law for righteousness” (no more works) —> “who believes”
In conclusion, we ‘keep’ the Law to “not” sin by using it to determine “what is a sinful act” (‘knowledge of sin’) e.g. obeying the Ten Commandments and the rest of the Principles in the Law which may be helpful to determine whether an act is sin or not.
Again, a reminder (obey His Word):
“nevertheless knowing that a man is not justified by the works of the Law but through faith in Christ Jesus, even we have believed in Christ Jesus, so that we may be justified by faith in Christ and not by the works of the Law; since by the works of the Law no flesh will be justified.” (Galatians 2:16)
If anyone argues contrarily, then he must explain what’s the definition for the “works of the Law” (“works“) which the Bible is saying one “cannot” be justified of?