Starting with iOS 15.2, you can add a Legacy Contact for your Apple ID. Adding a Legacy Contact is the easiest, most secure way to give someone you trust access to the data stored in your Apple account after your death. The data may include photos, messages, notes, files, apps you've downloaded, device backups, and more.
How to add a Legacy Contact
Tap your name
Tap Password & Security
Tap Legacy Contact
Tap Add Legacy Contact - you may need to authenticate with your Touch ID, passcode, or Face ID
Your iPhone will first suggest the contacts in your Family Sharing Group if you're in one
Tap Choose Someone Else if you want a contact that's not in your Family Sharing Group
Select a contact you want as your legacy contact
Share your access key - this is important as it gives your selected contact to access your data
Tap Print Access Key or Send Access Key
Certain information, like movies, music, books, or subscriptions you purchased with your Apple ID, and data stored in your Keychain—like payment information, passwords, and passkeys—can’t be accessed by your Legacy Contact.