Welcome to TRS
You have a few more issues
2004 has a digital dash(computer controlled) so that will have to be swapped out because 2004 computer will be gone.
2003 and earlier still had analog dash/instruments
I assume 2004 is an automatic, so has the column shifter
And both Explorer and Ranger are 2WD or both 4x4s
You needs to used the explorer transmission with the V8, thats what 1999 computer can control
1999 V8 computer will have PATS as well so not really an issue, you have a few choices.
If you have working PATS keys for the 2004 then they can be added to the 1999 computer by a mobile Locksmith, this can only be done once computer is installed in the new vehicle and working, i.e. powers up, but.............
If explorer is complete and you can at least turn it on, power computer up, then locksmith could add the 2004 PATS keys to 1999 computer before you disassemble engine and wiring, so it is ready to go on install
Or if you have working PATS keys for the 1999 computer you can remove 2004's ignition cylinder take it to a locksmith and have them re-pin key cylinder to work with 1999 keys.
But doors would use the original keys, they can be re-pinned as well.
Speedometer will not be a big issue but you will need a speed interface device.
Your 2004 will have an ABS speed sensor on the rear axle, that was used on the 1999 explorer BUT it used a GEM(module) to convert the ABS pulse to true speed pulse for speedometer and computer
The Dakota Digital SGI-5E can do that conversion:
http://www.dakotadigital.com/index.cfm/page/ptype=product/product_id=126/prd126.htm
Wiring is pretty simple, depends on which year instrument cluster you get
IMO the dash conversion will be hardest wiring part.
You will be in the dark for the most part, most find an '03 or older for this swap
You could get 1999 Explorer EVTM(electric vacuum technical manual)
And a 2004 Ranger EVTM
These are NOT Chiltons or Haynes manuals, lol, these detail every wire and what it is and where it is.
Ford sends them out to Dealers shops for each model each year, so you will find then for sale on ebay or ??
Must be for the EXACT year of vehicle.
Ford Shop Manuals included an EVTM but Shop Manual sets are often missing the EVTM because it was always being used, lol.