If I was a bettin' man, I would bet you've got a transfer case that's suffering from the infamous shift rail bore issue. The fact that it was grinding when you would shift to park tells me that the transmission output shaft is spinning (since that's where the park pawl is) but that power is not getting through the transfer case. There are several possible causes... the transfer case shift motor can stop in the 'neutral never-never-land', but shift motor failures on second-gen Explorers are notoriously uncommon. The shift rail bore tends to wear out, and then the shift rail fails to hold the gears in position. Generally this manifests itself as a buzzing or grinding noise on coast-down, say at freeway speeds when you let off the gas, and goes away when you step on the gas again. It eventually results in the gears slipping into neutral, and sometimes staying there. Shifting to low range and back into high sometimes moves the gears far enough to engage the forward direction, and the forward-pressure actually holds the gears in place (due to the helical cut of the gears). But shift to reverse, or coast-down again, and the problem will often re-surface.
The other possibility that comes to mind is an issue with either the shift rail itself, or the range fork not holding the gears in place. Omega Engineering makes some redesigned components to repair those issues.
The only way to know for sure is going to be to open yours up and see what's going on in there. There are several write-ups on them... Unfortunately, for your 97, to swap in a used one, you need one from a 97 specifically. A 95-96 44-05 transfer case won't have the proper front output shaft, and the 98-01 won't have the speed sensor you need in the rear half of the case. There are several members here that have built hybridized cases (back half from a 97, front half and guts from both a 97 and 98-01), but it's not exactly a fun thing to do.
That's my best guess at this point... sorry to be the bearer of bad news....