I do not have first hand experience owning a 4.0 V6 from the 4th gen 4runner... however, referencing this recent thread:
Should I get a v6 or v8
I would expect if it had consistent headgasket problems, or unusually high failure components, it likely would have come up. From what I've read, it's a solid motor. However, like all "all-aluminum" motors... one good overheat and it might be toast.
The 3.4L (5VZ-FE) is a stout motor. I've owned two different trucks with them and they've never let me down. They drive nice, easy to maintain. I'd really struggle to find you a fault.
If you want something reliable, just avoid the 3.0L from the 2nd gen 4Runner. They're great trucks, but when those motors start having problems, they get right expensive really fast. And they call it the 3.slo for a reason.
The 3RZ-FE that came in the 3rd gens are great motors, from what little people have said about them.
To be honest, I think you wouldn't go wrong with a well maintained 3rd or 4th gen truck. Going back in time for a 2nd gen would be ok if you know what you're getting into and really want that truck/body style.