The reason why rain smells so good is due to what's called Petrichor.
When the rain hits the soil it releases the smell of chemicals and plant oils along with producing bacteria and spores in the soil which cause the soil to smell when the rain hits it.
After it stops raining and the soil starts drying out then more spores begin to be produced in the soil and then you smell those spores growing.
That's why it smells so good after it rains and when it's raining too.