Hi,
I thought I'd share what I did to eventually get the correct password for the backup to restore. This is the situation I had:
My partner's iPhone 6 Plus had been running slowly, and Apple Support recommended restoring from a backup. So I installed a fresh copy of iTunes on my Windows 10 PC so that I could do the full backup (she didn't have enough space on her macbook).
I did the backup, leaving all the settings as the defaults (including the Encrypt iPhone backup setting; which I didn't even notice at the time).
After the backup had completed, I did a full reset of the iPhone (Erase All Content and Settings) ready for the backup to be restored.
I attempted to do the restore from iTunes, and it asked for the backup's password! I was very confused because I didn't specify a password at all during the backup! So, I tried her iCloud password, previous passwords, her mac's root password, and loads of other passwords that I thought it could be.
I eventually resorted to checking the key chain on her mac: Applications > Utilities > Key Chain Access, and searched for "iOS Backup". This held the original password she had used many years ago when she had previously backed up her phone to her mac.
So, in summary, if you are trying to restore a backup and it wants a password, and you didn't specify a password, it will be the password most recently set when doing a backup of that phone, even if that was on a different computer. (i.e. the phone must remember the password it last used during a backup).
I hope that helps others having the same problem.
Cheers,
Dan