Connect the laptop directly to the router using an Ethernet cable. You may need an appropriate Thunderbolt to Gigabit Ethernet Adapter if the laptop does not have its own Ethernet port.
If you have access to another Qualifying Mac, then you can create a bootable macOS USB installer using the instructions in this Apple article:
How to create a bootable installer for macOS - Apple Support
You will need to know the exact model of the Mac so that you/we can determine which versions of macOS are compatible with the laptop in order to identify a Qualifying Mac. A Qualifying Mac is one which can run an OS the other laptop can also run. You can get the exact model by entering the system serial number here:
Check Your Service and Support Coverage - Apple Support
This article can identify Qualifying Macs since it shows which versions of macOS are compatible with various Apple hardware:
https://eshop.macsales.com/guides/Mac_OS_X_Compatibility
Or you will need to figure out why you cannot connect to the WiFi. You did not provide any details on why you cannot connect to WiFi or how it fails with the WiFi. I can imagine multiple scenarios here.