It's essentially a large thermos bottle that consists of an outer housing, a tank and a burner assembly. Cold water enters at the top of the tank and flows through a plastic pipe called a dip tube, which delivers the cold water to the bottom of the tank where the burners are located. The heated water rises to the top of the tank where it flows out when needed. As hot water is drawn from the tank, more cold water enters the tank to be heated. The water is kept hot with a layer of insulation that is sandwiched between the tank and the outer housing.
Corrosion presents the biggest threat to a water's heat.
The water's chemistry combined with the high temperature creates a corrosive environment that can attack the tank, requiring its replacement. To prevent the tank from deteriorating, water heaters come equipped with an anode rod. The rod, also known as a sacrificial anode, is made of aluminum, zinc or magnesium. It attracts corrosive elements to keep the tank from deteriorating. The anode eventually will deteriorate completely - instead of the tank.