Excellent question!
The answer is … quite honestly, all of the above. If you have a will, you absolutely can leave your pokémon in the care of someone trustworthy, and in fact, many people do just this (often in addition to leaving their pokémon portions of their estate). Of course, for people who don’t have a will, their pokémon are often left in the care of their next of kin, any other blood relative, or a designated receiver such as a friend or significant other, and if one can’t be found, they’re placed in a pokémon shelter or left with breeders to be adopted by other trainers.
Incidentally, the storage system is set up to do this automatically. If you’ve signed up for a system account (which you are automatically if you’ve been given a trainer’s license), then the system will automatically recall your pokémon and send them to whomever you’ve listed as your emergency contact (who often is one of the above-mentioned relations) the moment you’re listed as legally deceased in your home’s national database. This way, even if you die abruptly on the road, your pokémon can be brought to a safe place.