If you've read the manual on engaging 4WD and low range, you should know that 4WD should only be engaged at lower speeds, but it's preferable to engage it while stopped, to avoid wear and tear on the transfer case and drivetrain. Low range can only be engaged while stopped, and only after 4WD has been engaged. If you hit the low range switch while in motion, the system is prevented from engaging it, but it can screw things up and wind up disengaging 4WD, either as a protective measure or just because that's how the system works.
If 4WD no longer engages even at a stop, you may have broken something internal in the transfer case electric shift motor. These are not cheap, which is a good reason to take it easy when engaging the 4WD system. It may be possible to remove the motor from the transfer case and diagnose the cause if anything internal appears broken.
If you've been reasonably gentle with the system, it can also just be finicky electronics from age. I've had the 4WD click off on mine when engaging low range at a standstill, and sometimes you have to engage 4WD again and then engage low range again. Sometimes you might even need to unlock the hubs, then shut off the vehicle and re-start it to 'reset' the 4WD module.
From what I've seen, it seems that regular use of the 4WD and low range functions, and engaging them in a predictable manner each time seems to make the system work more consistently. If you have the ability, it's also not a bad idea to pull the driver's side interior panel and have a look at the circuit board for the 4WD module to be sure it's in good shape (the capacitors can leak from age and damage the board, giving weird engagement/disengagment issues), and also checking out the wiring and such to the transfer case shift motor.
As a last resort (or maybe the first, since it's fairly easy to replace), the switch itself can go bad, sometimes just from age, other times from being pushed on too hard, so of course in those cases the only fix is a new switch.