See the steps in the article Solve internet connection problems on Mac - Apple Support
See also
If you can’t connect to a Wi-Fi network on Mac
Troubleshoot connecting your Mac to the internet
Troubleshoot external networking devices on Mac
Follow the steps in this old article How to troubleshoot Wi-Fi connectivity - Apple Support
Read Recommended settings for Wi-Fi routers and access points – Apple Support
The Apple ID password can still be found from keychain access View the information stored in a keychain on Mac - Apple Support , when iCloud Keychain was set in Mac Set up iCloud Keychain - Apple Support
Note : you might have changed Apple ID , still old Apple ID password is still in keychain access , open keychain access from Mac spotlight ( type keychain access in Mac spotlight , it will directly open ) , now from keychain access own spotlight , type old Apple ID in the spotlight , it will be high lighted double click on Apple ID address , check mark show password , you have to enter admin password the old Apple ID password will be shown .
In keychain access click on iCloud , the password section has to be selected .