Diagnosis
The setup wizard is finicky, especially on dual-band networks. It often fails if your router is broadcasting both 2.4GHz and 5GHz under the same name (SSID). The printer needs the 2.4GHz band.
How to Fix It
Go into your router's settings (on your phone or computer) and temporarily create a separate, unique network name (SSID) *just* for the 2.4GHz band. Something like 'HomeNetwork_2G'. Then, run the printer's wireless setup again and connect it to that new network name. Once it's connected and working, you can often hide that SSID later.
If That Didn't Work
Try the WPS method. Press and hold the Wi-Fi button on the printer's control panel for 3 seconds until the light flashes. Then, within 2 minutes, press the WPS button on your router. It should connect automatically.
Heads Up
The initial software installation from the computer often tries to push you to use HP Smart. If Wi-Fi setup fails repeatedly, connect via USB cable first to finish the computer setup, then try configuring Wi-Fi from the printer's own control panel menus.