Some species of cedar, redwood, locust, cypress, and so forth will easily withstand 20 years or more of contact with the soil. Other types of wood will rot out in five years, and then there are termites and carpenter ants to consider.
Pentachlorophenol (penta) is probably the best wood preservative