Studies have shown that cosmic rays entering thunderclouds ionize the air in thunderclouds, which in turn produces many suspended free electrons around  The electric field already in the clouds makes the free electrons carry higher energy
Lightning is produced in the process of snowstorm discharge
 When existing electrons in the air collide with water molecules, more electrons are released, which the researchers call a high-energy snowstorm, resulting in a escape collapse, a discharge process known as lightning