The connection is virtually non-existent.
Philosophy is the analysis of concepts.
The law is not an analysis of anything.
The law is a set of rules, along with a few vague precepts that supposedly glue those rules together (but don’t).
A nation’s laws are not derived from first principles. Nor can they so derived.
A nation’s laws cannot be deduced from one another. Nor should they be capable of being so deduced.
A nation’s laws cannot be read off of facts about that nation’s culture, its economy, or its politics.
A legal system is not a system of logic, epistemology, or ethics. No consistent system of logic, epistemology, or ethics is (or should be) embodied in a nation’s legal system.
Philosophical systems are general. They do not deal with contingences. They are derived from first principles.
Legal systems do nothing other than deal with contingences and are therefore not derived from first principles.
Sometimes jurists and philosophers retrospectively project philosophical principles back into pre-existing laws.
But you cannot derive those same laws from those same principles. Or rather, you can derive infinitely many distinctive and mutually inconsistent sets of laws from those some principles—showing that those laws do not in fact embody those principles.
Obviously bits and pieces of philosophy can be found dispersed throughout a given a legal system. But those specks of philosophy are just that—specks—and they are always after-the-fact.
If you devised a legal system on the basis of purely philosophical principles. it would not last one minute in the real world. The very first divorce or land-dispute that it had to deal with would decimate it—for much the same reason that a military strategy based on purely philosophical principles would prove useless after the first minute of battle.
There are philosophical truths about legal systems. But those truths have absolutely no operational significance, either for working lawyers or for judges.
Philosophy has manifold real-world applications. (In fact, true philosophy is a distillation of practical insights.) But the law—both the study and practice of it—is one place where those applications are not to be found.
When philosophers write about the law, their work tends to have philosophical merit only to the extent that it has nothing to do with the law. Sidgwick wrote brilliantly about the ethical foundations of the law—but not so much as a single application of a single town ordinance could be derived from what he wrote. By contrast, H.L.A. Hart and Ronald Dworkin were practicing lawyers who philosophized about the law—but their work, if considered as philosophy, was strikingly incoherent.
Genuinely good philosophical work that seems to concern the law doesn’t.
Good intellectual work that actually does concern the law is not philosophical in nature—at all.
Good law is bad philosophy, and good philosophy is bad law.