From my experience with our Cherokee's.
If you have the rear dome light with a push button, the switch might be bad. I replaced mine with a small toggle switch.
OR, the slip on connections at the hatch lock might be dirty. Pull the inside cover, (use a couple of flat screwdrivers and you can save most of the fasteners) and clean the the connections.
While you have the cover off you might want to cut a 1 1/2 X 3 inch hole in the sloped part of the cover, then you will be able to lock & unlock the lock and also open the hatch from the inside.
Mike