I’ve always liked this 1997 essay — "Where Does Law Come From?" — by Bruce Benson. In it, Bruce explains why law is not synonymous with legislation. Here’s his concluding paragraph:
The lesson here is that law and governance are natural institutions
that arise out of people’s interest in prospering through production,
the division of labor, and trade. They do not depend on a central
coercive authority for their genesis. States can arise when a powerful
group, bent on institutionalized extortion, co-opt and alter existing
customary law to serve its own particular interests.
A fuller treatment of this vitally important subject is in Bruce’s 1990 book The Enterprise of Law: Justice Without the State.