It will generally need to be connected to a hardware device or access true random numbers from an online service. I've heard of such devices measuring radioactive decay to retrieve random numbers for example. If a device is unavailable random_device will fallback to a pseudo random generator.
So the function random_device first tries to 'delegate' the random number generation to CPU. If it fails, then to the OS, and finally to the psuedo random generator.