There are three primary sources of smells that commonly occur after rain.
The first, the “clean” smell, in particular after a heavy thunderstorm, is caused by ozone. Ozone (scientifically known as trioxygen due to the fact that it is comprised of three oxygen atoms) is notably pungent and has a very sharp smell that is often described as similar to that of chlorine.
Another generally pleasant smell caused by rain is the deep, earthy smell, which is strongest after a dry spell or particularly heavy rainfall. This smell is the result of a bacteria commonly found in the soil.
Certain microbes, particularly streptomyces, produce spores during overly dry periods. The longer the soil goes without rain, the more spores that are usually present. The smell isn’t actually caused by the spores themselves, though. Rather it’s caused by a chemical excreted during the production of the spores known as “geosmin.”
The third cause of after-rain-smell is largely due to oils secreted by various plants. These oils collect in the environment and, when it rains, certain chemicals that make up the oils get released into the atmosphere (usually along with geosmin) causing a familiar and inviting scent. Learn more here.