The answer to 'why is my water heater smells bad' is that a rotten egg or sulfur-like odor coming from your water heater is usually caused by a buildup of bacteria in the tank. This is a common issue, especially in areas with high mineral content in the water.
The bacteria feed on the magnesium anode rod inside the tank and produce hydrogen sulfide gas, which creates the unpleasant smell. This is not usually a sign of a serious problem, but it should be addressed to prevent further issues.