Your water heater has a sacrificial anode feature. It is a metal rod installed by the manufacturer. The rod is made of either magnesium or aluminum and is referred to as an anode rod. The function of the anode rod is to protect the iron tank from corrosion.
While we in the industry refer to this water heater part simply as "the anode rod", the proper term for it is a galvanic anode. A galvanic anode is the main component of a galvanic cathodic protection system. The way it works to protect your iron water heater tank depends upon the fact that iron of the tank is more "noble" than the anode. That is to say that the anode is more reactive while the tank is less reactive. The electrochemical potential of the water in the tank is more readily expressed toward the sacrificial anode than the iron of the tank. As the term implies, the anode is sacrificed. The magnesium or aluminum is converted to it's oxide form and is therefore consumed. Once consumed it must be replaced in order to continue the protection.
I must admit that I went to the school of Wikipedia on this topic. I use Wikipedia constantly, not only for this work but also for my creative writing and general knowledge. I financially contribute to Wikipedia, happily.
I found the entire topic to be fascinating as I was carried from sacrificial anode to galvanic anode and then to electrochemical reactions, iron oxide, redox, electrochemical potential, and on and on. I did not cut and paste from any Wikipedia page for this page.
I found an informative website while I researched this topic and I thought I would share the URL with you. I have emailed back and forth with the owner of the site and discussed creating a link, as I think is proper. You will find his page on anode rods at: http://www.waterheaterrescue.com/pages/WHRpages/English/Longevity/water-heater-anodes.html
I have not done a great deal of linking on plumbing-geek but I liked the tenor of this site.
There are two common ways for anode rods to be installed. Some are threaded into a separate port at the top of the tank, these may be visible as hexagonal bolt heads within a round breach in the lid of the tank's jacket. The breach may be covered by a plastic press in shield. Otherwise you may find the anode rod joined to the hot water outlet nipple of the tank. I have always found the rod in it's own port to be difficult to remove where the outlet nipple of the tank is not only easier to find and get at but easier to turn. I would install a new rod at the hot water nipple as long as the temporary removal of the connecting pipe did not create new problems.
The other consideration when replacing an anode rod is the required space to fit a long rigid rod into the top of the tank. If you don't have the overhead clearance to do this, rods that are formed as sections linked together are available.
Eventually I will post a photo of a jointed rod here but I have procrastinated enough over quality photos and should get this page published. I will update these photos as I may, currently I am quite busy with restoration projects.
The friendly folks at Clancy Supply here in Portland Oregon kindly allowed me to photograph there stock. Here are a few anode rods. The one on the right and top threads into the hot water outlet port of a water heater. The one on the left and bottom threads into its own port in the top of the tank.