If you want to keep your 4WD, you'll need to use a transmission that is set up to accept a transfer case. Advance Adapters used to make a kit to mate a T5 to a stock Ranger case. Unfortunately, that kit is out of production.
Another way is to use a junkyard manual transmission and t-case out of a full size Ford 4x4 that was powered by a 4.2, 4.9, 5.0 or 5.8. This is possible but can have tunnel clearance issues depending on which parts are used. Also watch out for shifter placement and clearance issues between the t-case and left frame rail. Custom length driveshafts will be needed front and rear. Some possibilities are the M5OD-R2 (larger version of your M5OD-R1 Ranger transmission) and ZF (very large, very strong and very expensive).
If your Ranger has an 8.8 rear axle, it should be OK with a mild 302. If you have a 7.5 axle, you should swap to an 8.8 or better.
Here is some useful info for 5.0 swaps into 97 and earlier Rangers: