So now lets look at the full context of James 2:8 which is prefaced by James 1:27:
religion pure and undefiled with the God and Father is this, to look after orphans and widows in their tribulation — unspotted to keep himself from the world. (James 1:27)
1 My brethren, hold not, in respect of persons, the faith of the glory of our Lord Jesus Christ, 2 for if there may come into your synagogue a man with gold ring, in gay raiment, and there may come in also a poor man in vile raiment, 3 and ye may look upon him bearing the gay raiment, and may say to him, `Thou — sit thou here well,’ and to the poor man may say, `Thou — stand thou there, or, Sit thou here under my footstool,’ — 4 ye did not judge fully in yourselves, and did become ill-reasoning judges. 5 Hearken, my brethren beloved, did not God choose the poor of this world, rich in faith, and heirs of the reign that He promised to those loving Him? 6 and ye did dishonour the poor one; do not the rich oppress you and themselves draw you to judgment-seats; 7 do they not themselves speak evil of the good name that was called upon you? 8 If, indeed, royal law ye complete, according to the Writing, `Thou shalt love thy neighbour as thyself,’ — ye do well; (James 2:1-8)
15 `Ye do not do perversity in judgment; thou dost not lift up the face of the poor, nor honour the face of the great; in righteousness h6664 thou dost judge thy fellow. 16 `Thou dost not go slandering among thy people; thou dost not stand against the blood of thy neighbour; I [am] Jehovah. 17 `Thou dost not hate thy brother in thy heart; thou dost certainly reprove thy fellow, and not suffer sin on him. 18 `Thou dost not take vengeance, nor watch the sons of thy people; and thou hast had love to thy neighbour as thyself; I [am] Jehovah. (Leviticus 19:15)
The context is about not showing favoritism, especially not respecting rich above poor or vice versa.
The Royal Law in James 2:8 probably is most confidently interpreted as “chief instruction” since Thayer’s lexicon says the word βασιλικός is:
metaphorically, principal, chief: νόμος James 2:8 https://www.blueletterbible.org/lexicon/g937/kjv/tr/0-1/βασιλικός, -ή, -όν (< βασιλεύς),
[in LXX for מֶלֶךְ and its cognates ;]
royal, belonging to a king: χώρα, Act 12:20; ἐσθής, Act.12:21; νόμος β., a supreme law, “a law which governs other laws and so has a specially regal character” (Hort), or because made by a king (LAE, p. 3673), Jas.2:8; τις, one in the service of a king, a courtier, Refs (WH, mg., βασιλίσκος).†
Also, the word νόμος or “law” in the sense of that time was closer to “instruction” today since ancient law was more malleable and adaptable to new situations than ours–many instructions in the Torah do not even apply in a legal sense. This is to say that James is reaffirming what Jesus said about love of neighbor being the most important commandment and Jesus in turn is reaffirming what Hillel said:
That which is hateful to you, do not do to your fellow. That is the entire Torah, and the rest is commentary. Now go and study.
Jesus just formulated it in a positive affirmation. However, in addition to this interpretation I want to give an alternative here that I also think is interesting–that of fair or straight/even instruction.
On Isaiah 40:4 the Jamieson-Fausset-Brown Bible Commentary says:
Eastern monarchs send heralds before them in a journey to clear away obstacles, make causeways over valleys, and level hills. So John’s duty was to bring back the people to obedience to the law and to remove all self-confidence, pride in national privileges, hypocrisy, and irreligion, so that they should be ready for His coming (Mal 4:6; Lu 1:17).
In addition, walking straightly or fairly is used as a metaphor for following the instruction of God (see Psalm 23:3 mentioned later).
If you look at the context of James 2:8 you see that it is about treating people fairly despite wealth, this is paralleled in Lev 19:18 where it quotes “love your neighbor” from just a couple verses before in Lev 19:15. There it says this is done by righteous i.e. צֶדֶק transliterated “ṣeḏeq” (h6664) https://www.blueletterbible.org/lexicon/h6664/kjv/wlc/0-1/ sometimes translated as “justice” has a more positive rescuing context than in our legal system.
15 You shall not render an unjust judgement; you shall not be partial to the poor or defer to the great: with justice you shall judge your neighbour. 16 You shall not go around as a slanderer among your people, and you shall not profit by the blood of your neighbour: I am the Lord.
17 You shall not hate in your heart anyone of your kin; you shall reprove your neighbour, or you will incur guilt yourself. 18 You shall not take vengeance or bear a grudge against any of your people, but you shall love your neighbour as yourself: I am the Lord. (Leviticus 19:15-18)
Also, if you look at the context of most of the usages of “tzadik” h6664 or righteousness it is about judging fairly or not crookedly especially in regard to the poor. Also, the first definition Gesenius has for tzadik h6664 https://www.blueletterbible.org/lexicon/h6664/kjv/wlc/0-1/ is “in a physical sense straightness” and in Psalm 23:3 Gesenius says it is used to mean “straight paths” in
My soul He refresheth, He leadeth me in paths of righteousness, h6664 For His name’s sake, (Psalm 23:3)
Also the first definition Gesenius has for h6664 https://www.
Before Jehovah, For He hath come to judge the earth, He judgeth the world in righteousness, And the people in uprightness! h4339 (Psalm 98:9)
The same word “ṣeḏeq” or “righteousness” is paralleled by מֵישָׁר mêšār (h4339) “uprightness” or “equity” in Psalms 98:9 which also means “straightness.” https://www.blueletterbible.org/lexicon/h4339/kjv/wlc/0-1/
Before Jehovah, For He hath come to judge the earth, He judgeth the world in righteousness, (h6664) And the people in uprightness! (h4339) (Psalm 98:9)
And the strength of the king Hath loved judgment, Thou — Thou hast established uprightness; h4339 Judgment and righteousness h6666 in Jacob, Thou — Thou hast done. (Psalm 99:4)
Melchizedek is an old Canaanite name meaning “My King Is [the god] Sedek” or “My King Is Righteousness” (the meaning of the similar Hebrew cognate). Salem, of which he is said to be king, is very probably Jerusalem. Psalm 76:2 refers to Salem in a way that implies that it is synonymous with Jerusalem, and the reference in Genesis 14:17 to “the King’s Valley” further confirms this identification.
And the strength of the king Hath loved judgment, Thou — Thou hast established uprightness; (h4339) Judgment and righteousness (h6666) in Jacob, Thou — Thou hast done. (Psalm 99:4)
One might also take this as not showing favoritism by a fairness/evenness because we are all equally made in the image of God and the royal instruction is to walk with straightness past the superficial and get to the essence of God in man. This is because love of God is the other greatest commandment that Jesus mentions yet it can also be summed up with loving your neighbor. Similarly, Yehuda Shurpin says about Hillel’s teaching. Despite trying to make the case that it is different than the golden rule I think it is great how close it comes to what this article is talking about:
Hillel’s teaching can be read thusly:
“What is hateful to you”—having one of your shortcomings revealed—“do not do to your fellow”—do not expose his faults and imperfections, whether in worldly matters, in his relations with others, or in his spiritual behavior. Do not make them noticeable and concrete. Instead, let your love for them cover over their faults to the point that they evoke no repulsion, just like your own.
When you love a person because of his or her very soul, no (external) shortcomings will interfere with this love, and any perceived evil will be swallowed up by the love.
When we understand that our souls are all one and do not see each other’s flaws, G‑d also overlooks our flaws and blesses us with an abundance of good—including the future Redemption, “the day that is all good.”