Water heaters have a lifespan of 10 to 20 years depending on the quality of the water heater and how well cared for the water heater is.
I've replaced water heaters in homes I've lived in that were 20 years old when they started leaking and others I've replaced as early as 10 years after it was installed.
Still 10 years is a pretty long time for a water heater to last so I'm happy if I get 10 years out of a water heater.
I just save money in a savings account so I'll have enough money to replace the water heater when it does go bad.
You can help extend the life of a water heater by flushing the sediment out of the water heater on a yearly basis.
To flush the Sediment out of the water heater just hook a garden hose to the spigot on the water heater drain and then let the water drain completely out of the water heater and then with the hot water side turned off turn the cold water side on to help force the sediment out of the water heater and let it run this way for 30 minutes or until most of the sediment comes out.