The '04 uses a sensor in the differential for speed signal. I think yours gets it's speed signal from the transmission. So, that may be a problem. You would need to check if the speed pick up is in the transmission or the transfer case. If in the transfer case, you should be good. If not, the '04 transmission may have the hole needed plugged or blocked off. I've never had a Ranger that old. So I don't know what to look for and where to look for it.
The gear ratios between the two transmissions are the same according to this chart:
https://www.therangerstation.com/tech/ford-ranger-manual-transmissions/#gsc.tab=0