Thunderstorms are formed due to instability of the air and the presence of moisture. When the sun heats up the Earth's surface, warm air is forced to rise up while cold air sinks. Due to the difference in density, there will be instability in air and thus contribute to the formationĀ of a thunderstorm. I hope this helps.