If the affected fuses under hood and dash are in best shape, a bad shift motor ground wire could be a reason,
maybe corroded plug contacts, but in most cases the 4x4 shift motor itself is the trouble maker.
Unbolting it and see if it is rotating, while someone activates the 4x4 switch.
If it rotates try to move the shaft with a visegrip, hoping that it spins freely.
A bad 4wd shift module would cause trouble codes, if you are able to read them out
this could be a start.
Did your 4 wheel drive was functional before battery was disconnected?
Any blinking dash lights?
Regards Wolfgang