The answer to 'my water heater smells bad' is that a rotten egg or sulfur-like odor coming from your water heater is typically caused by a buildup of bacteria in the tank. This is a common issue that can be resolved with some simple maintenance.
The most common cause of this smell is the growth of sulfate-reducing bacteria, which feed on the magnesium anode rod inside the water heater and produce hydrogen sulfide gas as a byproduct. This gas has a distinct rotten egg odor. Other potential causes include a leak in the tank, sediment buildup, or a malfunctioning thermostat.