Electricity is a complicated concept that really wasn't discovered, investigated, and formalized as a concept by any one person. Instead there was an entire western scientific community that was exploring it over a period of centuries. Going from Gilbert's experiments isolating electrical attraction to Edison and Tesla was about 300 years.
I honestly don't think all this was doable in even that kind of time-frame without the printing-press. You need some kind of mass communications infrastructure that would allow that amount of educated people to collaborate and hear about each other's work. The Renaissance period (whether people realize it or not) is essentially synonymous with "after the printing press".
If I were to try to do it before then, I'd go with something like the following:
In the early medieval period, when Christianity was competing with German Heathenisim in Europe, there was a bit of a setback. Perhaps the son of Harald Bluetooth was electrocuted ringing a church bell in attempt to scare off the "air demons" in a lightning storm. It was pointed out to the king that this was clearly Thor's displeasure, and that He obviously makes a special target of all those pointy-steepled Christian churches. Non-Christians all over Europe make a habit of erecting giant crosses in open fields near storms, just to celebrate when Thor strikes them down.
Ensuing events set back Christianization of German areas by centuries. This caused the Catholic church to see lightning strikes on churches as an existential threat to the church, and to devote their top minds to the effort of studying lightning. The effort would also have the full support of the entire international communications infrastructure of the church. The greatest minds of Christendom were sought out and educated specifically for this purpose. Everyone down to the local parish priests was trained to consider identifying smart kids to their bishops as part of their duties.
With this system in place, this one topic had the finest minds in Europe working on it. Perhaps three generations of Newton-level thinkers were devoted to the task (where without this effort they would have wasted their lives as serfs).
The part I'm kind of fudging here is somebody (perhaps a Pope?) having the insight that lightning was a natural phenomena that can be studied, rather than an "act of God". I'm not entirely sure the Medieval mind was capable of that jump.