It’s not random; there is a specific algorithm to determine if you can use FaceID or need the passcode. The most basic:
- After you have restarted the phone it requires a passcode
- If you power off the phone you need the passcode.
- If you haven’t used Face ID for a long time (several hours) you need the passcode
- If you haven’t unlocked the phone for a longer period of time you need the passcode
- If you go to the Shutdown screen, but don’t shut down you need the passcode
- If you press the Side button 5 times quickly you need the passcode
There are a bunch of other rules that I don’t remember. But the reason is your biometric data is stored in an encrypted “secure enclave” in the processor chip and your passcode is the encryption key. When you start the phone after power off or restart your face scan is copied from the secure enclave into RAM. But RAM is erased when you shut down the phone or after other timeouts, so the passcode is needed to access the secure enclave and retrieve it.