'98 Ranger had a 4.0l OHV motor
'99 Explorer had a 4.0l SOHC motor
These motors are not related, they are 4.0l displacement and have close match on trans bolts, but other than that they don't share alot of parts.
4.0l OHV to 4.0l SOHC is not a common swap without computer and wiring swapped with it.
The Explorer V8 swap is common but requires wiring and computer swap.
The 4.0l OHV computer can manage the SOHC engine because MAF systems are adaptable, and with PATS on the '98 it is best to leave it alone unless you can get the full wiring with computer and PATS module plus keys from donor vehicle.
Yes, Ford changed the type of CPS used, you need to use the sensor that the '98 computer can understand, so you can't just splice a different connector on.
2 wire is Variable Reluctance sensor, this is the newer type
3 wire is Hall Effect sensor
I am not sure if you can just change the sensor, from quick look I would say no.
I did come across this thread discussing converting Variable Reluctance signals to Hall Effect signals, but not sure of the outcome??
http://www.explorerforum.com/forums/showthread.php?p=2960084