When a device is manufactured, within the ROM (read-only memory) a public key is "burned" into it. This public key matches a private key from Apple, which is not stored on the device.
Let us refer to the device as "Bob" and Apple as "Alice".
Bob wants to check if a version is signed so they can restore to it. The only way Bob can do this is with the help of Alice. Bob, with their public key, asks Alice, "Is this version signed?"
Since the public key matches Alice's private key, Alice knows 100% with certainty that the message comes from Bob. Alice then returns one of the following answers: "Yes" or "No".