Both are fine mills. The 3.0L is a Vulcan, a pushrod, 12-valve V6 sourced from the Taurus and Sable. While it gives up little horsepower to the 4.0L, it gives up quite a bit of torque.
The 4.0L is an evolution of the Cologne 2.8L, going back to the early 1980s. More famous than the 2.8L was the 2.9L, used very widely in the Ford Ranger and it's platform stablemate, the Bronco II, during the 1980s. Like the engines before it that put V6 power in a small truck on the map, the 4.0 is a durable, solid mill.
My experience has been that the 4.0L only surrenders about 1 MPG or so to the smaller 3.0L six, so there's little reason not to opt for it.
If I were looking for a Ranger, I'd ferret out one from 1983 to 1988 with a 2.9L V6. I much prefer the look and feel of that era Ranger, though the ones since then are hard to argue with. Great trucks, all.