Marc Lange, author of Because Without Cause, offers some thoughts:
Scientists discover laws of nature by acquiring evidence that some apparent regularity is not only never violated but also could never have been violated. For instance, when every ingenious effort to create a perpetual-motion machine turned out to fail, scientists concluded that such a machine was impossible – that energy conservation is a natural law, a rule of nature’s game rather than an accident. In drawing this conclusion, scientists adopted various counterfactual conditionals, such as that, even if they had tried a different scheme, they would have failed to create a perpetual-motion machine. That it is impossible to create such a machine (because energy conservation is a law of nature) explains why scientists failed every time they tried to create one.
Laws of nature are important scientific discoveries. Their counterfactual resilience enables them to tell us about what would have happened under a wide range of hypothetical circumstances. Their necessity means that they impose limits on what is possible. Laws of nature can explain why something failed to happen by revealing that it cannot happen – that it is impossible.
Mark Lange, “What is a law of nature?” at Psyche (March 10, 2022)