Check you electrical connectors to the Transfer case for corrosion. Also check you alternator is doing what it should. If you bring the revs up a bit then switch and it works, that may be the issue.
I had a similar experince. Found myself stuck on a beach and the transfer case went through...