This is usually from the various contaminants in the water supply. It builds up over a period of time. Usually when the water is already black, the water heater will need to be replaced. The tank is probably corroded and the sentiment in the bottom may not all come out. You can try flushing the system first. Connect a water hose to the drain valve and open it and the relief valve. You can also try chlorinating the tank per directions:
After removing the existing anode rod, household bleach must be added to the water heater tank at a ratio of one (1) cup for every (5) gallons of water heater capacity. Bleach may be poured directly into the anode opening or through any other water fitting on top of the tank. Install the new less active anode rod (Part # 9001453) and refill the tank completely. Turn on each hot water tap slowly and allow the water to flow until the chlorine can be detected. Turn off the hot water taps and let the water stand in the hot water distribution piping for no less than 2 hours (Preferably 8-12 hours). Flush the complete hot water distribution system through each hot water tap after the chlorination treatment.
If this does not help the water heater will need to be replaced. I also suggest having a water sample taken, to determine if any equipment is needed to treat your water. If you need more assistance, you can resubmit your question with more details.