Use rot-resistant woods. A fence post made from black locust heartwood will last a hundred years in the ground. I somewhat recently helped my dad dig up and move several fence posts older than I am to be re-used in a new location. The sapwood gets spongy very quickly, but the heartwood doesn't quit. The main drawback is that it's relatively easy to split. If I'm splitting firewood, I'd rather be splitting locust or oak over hickory or cherry.