Forgetting an Apple Account password is annoying. Being locked out with no device that still knows it is worse. A recovery contact is the cheap fix, and you have to set it up while everything still works.
On an iPhone or iPad, open Settings, tap your name, tap Sign-In & Security, tap Recovery Contacts, tap Add Recovery Contact and follow the steps. On a Mac it is System Settings, your name, Sign-In & Security, Recovery Contacts.
Settings > [your name] > Sign-In & Security > Recovery Contacts
You can add up to five. Someone in your Family Sharing group is added automatically. Anyone else gets an invitation in Messages and must accept it. Both of you need iMessage turned on and devices on iOS 15, iPadOS 15 or macOS Monterey 12 or later. Apple notes the age limit is 13 and varies by country or region.
If you ever need it, you verify your information in the account recovery process and then ask your contact. They can help in person or give you a six-digit code, which you enter on your own device to reset the password. Apple says contacts have no access to your account, only the ability to give you a code.
Caveat: Apple doesn’t know who your contacts are, so you have to remember them yourself, and choose people you can actually reach. If you use Advanced Data Protection, a recovery contact is also one of the recovery methods it asks for.
Further reading: Set up a recovery contact for your Apple Account