When were how and by whom was electricity invented?

Electricity was not invented. The properties of electricity were discovered, and means of making use of them were invented, by many people over an extended period of time.