Benjamin Franklin didn’t discover electricity while flying a kite, he may not have ever flown the kite, but he certainly helped to advance our understanding of electricity through his scholarly research.
Did Benjamin Franklin Discover Electricity While Flying a Kite?
Electricity was written about and experimented with for at least a century, if not more, before Benjamin Franklin flew his kite in 1752. Franklin was trying to understand the nature of electricity and lightening in his famed kite experiment.
Some modern experts doubt the events surrounding the kite experiment took place at all; as it was impractical and there were no witnesses.  Proving it didn’t take place is difficult since different versions of the story exist, and it is nearly impossible to prove that an event like this did not happen. We look at the facts we do know below.This video explains Franklin’s kite experiment.
Did Benjamin Franklin Write About the Kite Experiment?
Franklin himself never wrote about performing the kite experiment. Instead he mentions it theoretically in 1752.  It wasn’t until 15 years later until Joseph Priestley wrote about the actual event happening, most likely with Franklin’s input.
Did Anyone Actually See Him Perform the Kite Experiment?
It’s theorized that, fearing that the test would fail, or that he would be ridiculed, Franklin only took his son to witness the experiment, and then published the accounts of the test in third person.
What is the Story behind the Kite Experiment?
The exact details of the story change depending upon who is telling it, but the gist of the official Joseph Priestley version goes like this:
Benjamin Franklin, wanting to test the electrical properties of lightening in a safe way, (the lightening rods he invented weren’t going to cut it alone) came up with an idea to attach a lightening rod to a kite. Inviting his son to join him, he picked a stormy day to fly a silk kite with a hemp line holding a metal key and a Leyden jar (jar that holds static electricity). Franklin connected the device to a piece of silk to insulate himself. After some time flying the kite, he noticed the fibers on the hemp line standing up as though charged. He touched the key with his knuckle and felt a charge from the accumulated electricity in the air, not from a lightning strike.
Touching the key directly after a lightening strike would have most certainly resulted in his death. 
History of the Kite Experiment
Benjamin Franklin never wrote about the kite experiment, but it was mentioned in various papers in 1752 including the notable theoretical mention of the kite-lightning experiment in the Pennsylvania Gazette in 1752. In this paper Franklin proposed an experiment with conductive rods to attract lightning to a Leyden jar, an early form of capacitor. 
It wasn’t until 15 years after the event that the story as we know it today was written by Joseph Priestley in The History and Present State of Electricity, with Original Experiments. There is no reason to assume that Benjamin Franklin wasn’t there to recount details to Priestley although, since 15 years had passed between the event and the written record, it’s hard to conclude that all recounted information was accurate.