How does keychain restore work in other idevice?

When you restore an iOS backup - all the previous contents are gone so there is no merging of old and new contents. You end up with the current keychain matching the backed up keychain.

The only subtle aspect is that if you do not have a passcode lock on the device, some items stored in the keychain are wiped (either not backed up or not restored - it's not clear when this happens). This ensures that you actually have to re-enter mail passwords and such.

This protects from someone restoring your backup without your knowledge and then being able to read your email. They either need to know your passcode or your password to make use of a restored keychain and app settings on a new device initially after restore.