Data on an iPhone is scrambled in an encoded and unreadable way which can only be decoded with the private, device-unique key.
That private key is stored inside a dedicated chip, the “Secure Enclave.” Without the key, the data is unreadable.
If the iPhone has a passcode set, that private key cannot be accessed without the passcode. Even with specialized tools, the encrypted data cannot be read from the phone without the user releasing the private key. The “Secure Enclave” hardware is designed so that the key cannot be directly read; data is decrypted by passing through the chip once it is unlocked with a passcode. If an attacker keeps randomly guessing passkeys, the delay between accepting keys grows exponentially with each bad guess, stopping a brute force guessing attack.
This very secure level of encryption makes governments very nervous, and they are frantically trying to outlaw this capability.