Well, I take the perfect law of liberty to be "love your neighbor as yourself," as described in Galatians 5:14. So it was indeed part of Old Testament law as you stated.
James calls "love your neighbor as yourself" the "royal law" (James 2:8). I don't think the royal law is the perfect law of liberty, but I do believe it is part of that perfect law.
What, then, is the perfect law of liberty? First, Psalm 19 says the Law of YHWH is perfect. It is a perfect law. Secondly,
James 2:8-12 tells us what the perfect law of liberty is.
“If you fulfill the royal law according to the scripture, Thou shalt love thy neighbor as thyself, you do well: But if you have respect to persons, you commit sin, and are convinced of the law as transgressors. For whosoever shall keep the whole law, and yet offend in one point, he is guilty of all. For he that said, Do not commit adultery, said also, Do not kill. Now if you commit no adultery, yet if you kill, you are become a transgressor of the law. So speak you, and so do, as they that shall be judged by the law of liberty.”
The law of verses 8-11 is the Old Covenant law. In verse 8, James is quoting the second greatest commandment which is actually an Old Covenant commandment found in
Leviticus 19:18. In verse 9, the law he is referring to is the Old Covenant law. Verse 10 is often used by those opposed to obeying the Old Covenant laws. They say, “if you break one law you’ve broken them all, so why even try to keep the law?” So verse 10 is also speaking of the Old Covenant law. Of course, verse 11 is quoting two of the Ten Commandments which are also Old Covenant laws. In verse 12, James is saying that people are going to be judged by that same law. So, in order to receive a good judgment, speak and do according to those laws.
Paul said the same thing in
Romans 2:12,
13, “For as many as have sinned without law shall also perish without law: and as many as have sinned in the law shall be judged by the law; For not the hearers of the law are just before God, but the doers of the law shall be justified.” Not that the law justifies us. We are justified by grace through faith. However, a saving faith (part of pure religious worship) will be evidenced by good works, among which include obedience to the law.
Why does James call the Old Covenant law “the law of liberty”? Well, there are two reasons. The first has to do with obedience. When the law is lawfully used, when it is obeyed through the motivation of love without seeking to be justified or saved by it, we walk at liberty.
Let’s look at
Galatians 5:13-16;
“For, brethren, you have been called unto liberty; only use not liberty for an occasion to the flesh, but by love serve one another. For all the law is fulfilled in one word, even in this; Thou shalt love thy neighbor as thyself. But if you bite and devour one another, take heed that you be not consumed one of another. This I say then, Walk in the Spirit, and you shall not fulfill the lust of the flesh.”
Paul then goes on to list the works of the flesh in vss. 19-21, all of which are transgressions against Old Covenant law. However, if we obey the law through the Spirit and through love, the law cannot put us in bondage. If we walk in the Spirit as the Spirit leads us to obey the law (Ezekiel 36:26-27), we walk in freedom and liberty.
Now, if we transgress the law and sin, the second reason why the Old Covenant law is the perfect law of liberty comes into play. It has to do with what Paul said to the Galatians in 3:24, “Wherefore the law was our schoolmaster
to bring us unto Messiah, that we might be justified by faith.”
In other words, one of the functions of the law was to lead us to Messiah in order to be liberated from sin. Our disobedience to the law drives us to Messiah and to freedom and liberty from sin through him. We were once imprisoned on death row because of our transgressions against the law. But now, the law has led us to Messiah and liberty. Once we are free from sin, Messiah then drives us back to obedience to the law through faith. We become doers of the word, or as Paul says, “doers of the law”, and not hearers only.
How do we know Yeshua is driving us back to obedience to the law through faith?
Romans 3: 30,
31 says;
“Seeing it is one God which shall justify the circumcision by faith, and uncircumcision through faith, do we then make void the law through faith? God forbid: yea, we establish the law.”
Why is the law being firmly established? Because Messiah is driving us back to obedience to it.