If engine over heated then heads are most likely bad as well.
You have a Vulcan 3.0l engine in there now and that is what you want to stay with.
Ford also used 3.0l Duratec engine is some vehicles, not the same as 3.0l Vulcan, no shared parts at all.
You can use any year Vulcan 3.0l from 1995 to 2008, 1994 and earlier had distributors.
List of vehicles that used them here: https://en.wikipedia.org/wiki/Ford_Vulcan_engine
Car or truck doesn't matter.
You will be switching over oil pan, and intake from your engine to "new" one, along with all pulleys and accessories
You might save a buck or two by pulling the heads now and taking them to a machine shop to be tested.
If they are OK then you just need a Short Block.
Swapping engine size is not for the faint of heart, there is no plug and play swap unless it is the same engine.
5.0l V8 is a popular swap into a Ranger because it "fits" with slight mods, and rolled, rusted or damaged explorers with 5.0ls seem to be available in most areas.
You need to get the whole explorer or mountaineer for parts.
Because you will need most of the parts, engine, trans, computer and wiring.
If you can't find a 2WD V8 then you can run with the transfer case, just have the extra weight but it will work fine with no front driveshaft
You also need the keys because of PATS(passive anti-theft system) in the computer.
Custom drive shaft in the rear
And swap over explorer rear axle which does take some welding, or get a Ranger 8.8" rear axle(added cost), needs to have ABS speed sensor.
You current 7.5" axle will break with V8 power although it won't happen immediately, so it can be a side project.
Point of the V8 is the POWER, so 7.5" will fold under pressure, lol, no matter how "easy" you promise to take it, you WILL floor it.
Wire connections between ranger dash and explorer computer isn't bad but there is some cutting and splicing.
And it is different between years of Rangers and Explorers, i.e. a 1998 Ranger will have different wiring than a 1999 or 1997 Ranger, same for explorer years, so there is no standard cross-match for every wire, most but not all.