Hydrocarbons contain only hydrogen and carbon, but fossil fuels such as coal and crude oil often contain impurities. A common impurity is sulfur or sulfur compounds. A pure hydrocarbon fuel would not produce sulfur dioxide.
When the fuel burns, the sulfur in it reacts with oxygen. The sulfur is oxidised to sulfur dioxide, SO2: S + O2 → SO2. Sulfur dioxide is a colourless, poisonous gas with a choking smell. It is released into the atmosphere in the waste gases from chimneys and exhausts.
The more sulfur there is in the fuel, the more sulfur dioxide is made. Removing sulfur from fuels before they are burned, as is done with petrol and diesel, means less sulfur dioxide is released.