Rule of law today is often confused as merely meaning the law rules, that is, if it is law, then it is right and just, in short, the law justifies itself.

But that's not origins of the meaning of rule of law as explored in this essay by FA Hayek, Decline of the Rule of Law.

We must once again redefine the ancient concept that freedom implies equality before the law and not arbitrary power for those who administer it.

...I suggest the answer lies in part in a Greek word which the Elizabethans borrowed from the Greeks but which has since gone into disuse; its history, both in ancient Greece and later, provides a curious lesson. Isonomia, which appears in 1598 in John Florio's World of Wordes as an Italian word meaning "equalitie of lawes to all manner of persons," two years later, in its Englished form "isonomy," is already freely used by Philemon Holland in his translation of Livy to render the description of a state of equal laws for all and of responsibility of the magistrates. It continued to be used frequently throughout the seventeenth century, and "equality before the law," "government of law," and "rule of law," all seem to be later renderings of the concept earlier described by the Greek term....

The history of the word in ancient Greek is itself instructive. It was a very old term which had preceded demokratia as the name of a political ideal. To Herodotus it was "the most beautiful of all names" for a political order. The demand for equal laws for all which it expressed was originally aimed against tyranny, but later came to he accepted as a general principle from which the demand for democracy was derived. After democracy had been achieved, the term continued to be used as a justification and later, as one scholar suggests, perhaps as a disguise of the true character of democracy: because democratic government soon proceeded to destroy that very equality before the law from which it derived its justification.

...A characteristic dispute between Hobbes and Harrington, from which, I believe, the modern use of the "government by laws and not by men" derives, indicates how 'alive these views of the ancient philosophers were to the political thinkers of the seventeenth century. Hobbes had described it as "just another error of Aristotle's politics that in a well-ordered commonwealth not men should govern but the law." Harrington countered that the "art whereby a civil society is instituted and preserved upon the foundation of common right or interest" is "to follow Aristotle and Livy ... the empire of laws, not of men."...

...To the seventeenth-century Englishmen, it seems, the Latin authors, particularly Livy, Cicero, and Tacitus, became increasingly the more important sources of political philosophy. But, even if they did not go to Holland's translation of Livy where they would have found the word, it was still the Greek ideal of isonomia which they met at all the crucial points. Cicero's Omnes legum servi sumus ut liberi esse possumus [we are all servants of the laws in order that we may be free] (repeated later, almost word for word, by Voltaire, Montesquieu, and Kant) is perhaps the most concise expression of the ideal of freedom under the law. During the classical period of the Roman Law, it was once more understood that there was no real conflict between freedom and the law, their generality, certainty, and the restrictions they placed on the discretion of the authority, which was the essential condition of freedom. This condition lasted until the strict law (ius strictum) was progressively abandoned in the interest of a new social policy....

...The main point is that, in the use of its coercive powers, the discretion of the authorities should be so strictly bound by laws laid down beforehand that the individual can foresee with fair certainty how these powers will be used in particular instances; and that the laws themselves 'are truly general and create no privileges for class or person because they are made in view of their long-run effects and therefore' in necessary ignorance of who will be the particular individuals who will be benefited or harmed by them. That the law should be an instrument to be used by the individuals for their ends and not an instrument used upon the people by the legislators is the ultimate meaning of the Rule of Law.

Since this Rule of Law is a rule for the legislator, a rule about what the law ought to be, it can, of course, never be a rule of the positive law of any land. The legislator can never effectively limit his own powers. The rule is rather a meta-legal principle which can operate only through its action on public opinion. So long as it is generally believed in, it will keep legislation within the bounds of the Rule of Law. Once it ceases to be accepted or understood by public opinion, soon the law itself will be in conflict with the Rule of Law.