Electricity is the behavior of electrons which is caused by the attraction of particles with charges that are opposite and the repulsion of particles that have charges that are the same.
Certain creatures evolved electrical attacks and defenses; notable examples include the electric eel of Earth, giant dry-worms of Antos IV, and the Capellan power-cat of Capella IV. (TOS: "Who Mourns for Adonais?"; TAS: "How Sharper Than a Serpent's Tooth") An intelligent lifeform called the Companion was composed largely of electricity; it could injure living beings and damage equipment by imparting an electrical charge to them. (TOS: "Metamorphosis")
The two humanoid species known as the Brekkians and the Ornarans had the ability to naturally release electrical charges, which they used in personal combat to subdue their opponent, among other things. They also appeared to possess a natural resistance to electricity compared to other humanoids. It was speculated that they may have evolved this ability due to the strong magnetic field of their sun. (TNG: "Symbiosis")