When a Windows phone is turned on for the first time or right after a hard reset, you are prompted to sign in or create a Microsoft account. It will also ask if you want to restore from an existing backup (more later).
The phone can be backed up automatically or on demand to that account.
Those backups can be restored to another Windows phone the first time it is turned on or after it is hard reset.
It won't restore all the apps but it will restore settings for apps that allow that when they are reinstalled. And if the new phone has a different screen aspect ratio or a different version of Windows, expect to do some tweaking.
You will have to reinstall all but the default apps, so make a note of those before you start...