There are a few possibilities, but we'll start with the most likely. On the right axle tube is the vacuum disconnect. It has a sleeve that slides to engage splines on the axle shafts together when you put it in four wheel drive. There are two vacuum lines on it-one for apply and one for release. Check these first. Start the truck up and check for vacuum on one line in two wheel drive. (You'll have to go under the truck-be very careful. Wheel chocks, helper holding the brake, etc) If that line has vacuum put it in four wheel drive and check the other. If they are both ok pull the disconnect off the axle and see if it moves when vacuum is applied to it.
If there is no vacuum to one side but ok on the other, check the vacuum lines from the transfer case to the axle for damage. If ok, replace the vacuum switch on top the transfer case. If you don't have vacuum to either line down there, check to make sure there is vacuum making it to the switch from the engine.