Lightning is a natural electrical discharge that occurs during thunderstorms when electrically charged regions in the atmosphere discharge, typically between clouds or between a cloud and the ground.
The primary reason for lightning strikes is the separation of electric charge within a thundercloud, leading to the buildup of strong electric fields.
Here's a more detailed explanation of the process: