It's unfortunate that when you want to get to the bottom of how something works, eventually you get beyond physics and into philosophy. How does a true random number generator work? Well, it might observe a naturally random physical phenomenon like the position of a photon and convert that random noise to a numeric value.

But was the photon's position random in the sense that it could have been otherwise? Or was it deterministic yet unknowable to observers?

Physics, in all its glory, must sometimes defer to philosophy. Regrettably.