Yes, the M5R1 from any year 4.0l will fit on any other year 4.0l, and yes, 4WD or 2WD must also match
One thing, the shifter setup was changed a bit in the 2001 and up M5R1, so get the 2005 M5R1 complete WITH shifter, as the 2000 shifter won't work on the 2005 transmission
Image here of the difference:
https://www.therangerstation.com/Magazine/January2011/M5OD-R1HD/m14.JPG
2001 and up M5R1 also had one extra bolt hole on bell housing, so 7 holes instead of 6, but the 6 match up on all year 4.0ls
The 4.0l SOHC engine just had an extra bolt
image here:
https://www.therangerstation.com/Magazine/January2011/M5OD-R1HD/m8.JPG
You can see the "7th" bolt hole at about 10:30, so left side of image near the top of bell housing
In 2001 the 4.0l M5R1 model number was changed to M5R1-HD because of these 2 changes
There will be an extra sensor on the 2005 transmission, an OSS(output shaft speed) sensor, it was used for speedometer in 2001 and up Rangers, 2000 doesn't need it so just leave it disconnected
See if you can get the Reverse light connector with the trans, 2000 and 2005 may have used different plug-ins
On all M5R1 transmissions check the 3 rubber plugs on back of shifter housing, they get old and brittle and leak
M5R1 uses ATF, Mercon V or similar synthetic, holds 2.8pints bone dry, so a quart and a half