Usually you have a group of "recovery phrases" that once entered into the device, it restores itself so you can still access the funds. There is more information how this works on a Ledger Nano S for example here: https://medium.com/@trionkidnapper/ledger-nano-s-restoring-a...