Realism/Anti-Realism has no bearing to the matter. I personally think mathematics is a priori and non-causal, and not necessarily correspondent to the real world. This would imply I'm technically an anti-realist. Certain mathematics correlates to the real world, others do not and are simply (interesting) mathematical structures.
Neither viewpoints can explain why certain mathematical statements actually correlate to reality. Mathematical entities are not causal - they do not have any causal connection to the real world since they are (obviously) abstract.
Maybe a good place to start thinking about this problem would be to read Wigner's work "The Unreasonable Effectiveness of Mathematics in the Natural Sciences".
What does random mean? Are you asking why the universe appears to be consistent and intelligible at all? Where would we be if it weren’t?
The weak anthropic principle covers this nicely. Perhaps it is an unsatisfying answer, but scientists and mathematicians aren’t usually in the business of answering ontological questions.
Maybe a good place to start thinking about this problem would be to read Wigner's work "The Unreasonable Effectiveness of Mathematics in the Natural Sciences".
I have studied all of this. Wigner’s account is very important for the debates it inspired but it’s far from the last word on the topic. There have been numerous replies addressing all of Wigner’s claims. Try reading Hamming’s replies to start.
"From all of this I am forced to conclude both that mathematics is unreasonably effective and that all of the explanations I have given when added together simply are not enough to explain what I set out to account for." - Hamming
In many cases, physicists are not so successful. Look at the current debates in particle physics and the grand unified theory. Progress has largely stalled.
In other cases, models are revised continually as new information comes to light. For example, the age of the universe as we know it may double [1] from 13.78 billion years to 26.7 billion years.
You might call this “unreasonable effectiveness,” I call it a process of messy refinement and rethinking over thousands of years, much of it later shown to be invalid, despite mathematical correctness.
[1] https://phys.org/news/2023-07-age-universe-billion-years-pre...
You might want to study a bit of philosophy of mathematics, particularly the bit on the realism vs anti-realism debate. A great deal of people fall into the anti-realism camp, and they would disagree rather vociferously with your statement about “mathematical laws.”