Apple wants a court order from a probate court giving them authority to provide access to a cell phone. The order requires
§ The name and Apple ID of the deceased person.
§ The name of the next of kin who is requesting access to the decedent’s account.
§ That the decedent was the user of all accounts associated with the Apple ID.
§ That the requestor is the decedent’s legal personal representative, agent, or heir, whose authorization constitutes "lawful consent.”
§ That Apple is ordered by the court to assist in the provision of access to the decedent’s information from the deceased person's accounts. The court order should be addressed to the relevant Apple entity.
See more information here.
It’s also quite easy to add a “Legacy Contact” in your phone that grants access to your phone after your death. this only requires a death certificate instead of a court oder.
Go to settings, tap your name, tap “Password & Security” then tap “Add Legacy Contact” and go from there. Again, go here for more information.
OTHER: Information about how to access a Google account can be found here.