The single most important factor in whether a water heater lives or dies is the condition of its sacrificial anode. This is a rod made of magnesium or aluminum that's formed around a steel core wire and is screwed into the top of the tank. Special aluminum/zinc sacrificial anodes or powered (impressed-current) anodes can be used to resolve odor problems caused by bacteria in some water. When the tank is filled with water, an electrochemical process begins whereby sacrificial anodes are consumed to protect a small amount of exposed steel. When two metals are physically connected in water, one will corrode away to protect the other. Sometimes that's bad, but often it's good.
All metals fall somewhere on the galvanic scale of reactivity. When two are placed together in water, the "nobler" -- or less reactive -- one will remain intact while the more reactive one corrodes. When steel and copper are together, steel will be the one that corrodes. Indeed, steel is more likely to rust in the presence of copper than it would have been by itself. That's why dielectric separation is necessary on items like copper flex lines when they're connected to steel nipples.
Magnesium and aluminum are less noble than steel, which is why they're used for anode rods. A sacrificial anode's life depends on the quality of the water, the amount of use the tank gets, the water temperature, and the quality of the tank -- meaning how well it was constructed. When salt is added to the water (as in softened water), anodes corrode more quickly. Water softeners help reduce sediment, but anodes can corrode in as little as six months if the water is over-softened. Do not soften to zero. Leave 50-120 ppm of hardness. This may require some plumbing to add unsoftened water to softened water.
People occasionally ask us if pipe-seal tape applied to the threads of the anode blocks the electrolytical reaction. Tanks we've serviced repeatedly usually have corroded anodes. We've tested with a multimeter and found continuity between the anode and the tank, despite the tape.
While we generally advocate putting two anodes in a tank, that may not be a good idea if you have odor problems. Doubling the anode surface area may worsen odor even when special aluminum/zinc anodes are used that reduce or eliminate the odor.
If you have odor and soften, or for that matter, merely if you soften, consider getting a powered anode that replaces the sacrificial reaction with electric current and isn't consumed through use.
If you contemplate adding an anode to a new tank, make sure both rods are of the same metal. Otherwise, the magnesium rod will be consumed more rapidly in the presence of an aluminum one and you won't get as long a life. How do you tell them apart? In nearly all cases, an aluminum hex head will be flat on top, while a magnesium rod will have a bump.