Buy a new nut--threads will be stripped on the old one
Get the Miller tool for the nut. You can put the trans in gear and use an engine barring tool so you don't need the Miller tool that fits the output splines.
Remove the lowest bolt of the driver's side pto cover and let trans drain. When you take off the tailhousing, it will drain anyway, but more messy that way. You also want to take off the left pto cover to clean the magnet and the bottom of the trans case because metal from the nut's threads may be there.
Remove transfer case--if 1997 back, there is wiring on the tailhousing of it for the speedometer. There is a vacuum "tree" connector on the top, and linkage on the trans for the transfer case.
Remove the crossmember (support the trans) and transmission tail housing. Now you can spray clean the splines on the main shaft and on fifth gear. Use red high temp loctite on the splines and the nut threads, install the new nut to at least 300 ft lb. You will be doing this again since you haven't replaced the beat up mainshaft with one fully splined under 5th gear.