Well you know it's working from the VSS to the speedo, and if your driven gear is good, bout the only thing left would be the drive gear on the transfer case.
If memory serves me it's a plastic gear that is attached to the T case output shaft.
It's what spins the driven gear that spins the VSS, that operates the speedo.
Could be it's stripped on the shaft and slipping.
4th one down here.
98 1998 Jeep Wrangler Speedometer Drive - Transmission - Automatic - Omix | Drivewire.com