Convection is the transfer of heat through the movement of a fluid. In the atmosphere, convection occurs when warm air rises and cooler air sinks. This process is driven by differences in density between warm and cool air. Warm air is less dense than cool air, so it rises. Cool air is more dense than warm air, so it sinks.
The rising warm air forms clouds. When the water vapor in the clouds condenses, it releases heat. This heat warms the surrounding air, which causes it to rise. The rising air forms more clouds, and the process repeats. This cycle of convection and cloud formation is what drives the weather.
Convection is also responsible for the formation of thunderstorms. When the air is very warm and humid, it can become unstable. This instability can cause the air to rise rapidly, forming thunderstorms. Thunderstorms can produce heavy rain, hail, and lightning.