That spring tensions the shifter towards the '2WD/4WD' side of the shift pattern. It should be in there. The shift lever rides up and down on the flat section of spring in the middle. Look at the orientation in the pic below.
Generally, you don't want to remove the cover for the shift lever. The 'correct' way to remove the shift lever is to pull the c-clip and leave the housing in place.
Of course, since you are looking to fix whatever is messed up below, you needed to remove that cap - but getting the lever in correctly is easier once the cap is in place. Also consider getting a new shift seat for the 4WD shifter, it is probably disintegrated (it is gone in the picture above, about to get replaced).
-Charlie
__________________
'99 4Runner SR5 Auto -
4WD swapped
'89 Camry Alltrac LE 3S-GTE 5spd
'17 Chevy Volt Premier
'16 Honda Odyssey Elite
Previous: '88 Camry Alltrac LE 3S-GE BEAMS, 90 Camry 3S-GTE, 90 Camry DX, '03 WRX wagon, '08 Outback XT