Whenever you connect to a WiFi network, your Android device will save the credentials so that you can connect to the same network again in the future.
This data is sent to Google's servers, but you have no way to retrieve it from the phone. If you do not activate phone backup on Google, the information will be lost if you change the device.
The WiFi settings (practically the SSID and the password for each connected network) are saved into a file. Depending on the Android version and the vendor, the file may have different name and location, here are some examples:
Passwords can be stored in encrypted form or in plain text. To replace the file you need root privileges.
Here it is the procedure to replace the existing file with your backup: