2001 to 2006 Ranger 4x4s(or similar year B-series) used the early version of the 4x4CM, control module, in 2001 to 2003 its behind the passenger side kick panel, says "4x4CM" on the label, 2004 and up its behind the Radio
These were known to fail over time
If you checked the 4 fuses and they are OK
Fuse 13 in ENGINE BAY fuse box
Fuses 5, 10 and 11 in Cab fuse box
Then turn on the key, 4WD lights should come on and then go off, that's a Bulb Test, nothing more
Change the 4WD knob to a new position
If the 4WD lights flash then 4x4CM is working and the shift motor on the transfer case is not moving, bad fuse 13 or bad shift motor
If no 4WD lights come on then its most likely the 4x4CM, it runs the dash lights
These are not cheap new, but wrecking yard replacements can be bad as well
Take the Ranger to wrecking yard with passenger kick panel removed, and swap in 2001-2005 replacement 4x4CM until it works
No HOT swaps, turn OFF the key before swapping modules, then turn key back on to test
2006 may work, but 2007-2011 will not work for sure
Just FYI
Its NEVER the dash 4WD switch, unless its been hit with a hammer and physically broken it just works, just has 3 resistors inside and 2 wires, very simple switch