I am going to take your question literally as regards "discovered", not because I want to be pedantic, but because the effects of electrostatics must have started any human with curiosity wondering about nature. In other words, seeing a lighting strike hitting a tree and hearing the thunder was possibly one of earliest of the Earth's physical phenomena that got humans thinking beyond themselves.
I think you have to make an important distinction here. Electrostatics was known about / discovered since since the first caveman (or cavewomen) put on a fur from an animal, and later saw sparks in their cave, or saw lighting.
I use these examples because our knowledge of electrostatics stayed at much the caveman level, until, as the other answers also say, Thales of Miletus, investigated the effect, around 500 BCE. Mostly, the effect on daily life was due to the triboelectric effect.
SOURCE: Wikipedia Electrostatics
The triboelectric effect is a type of contact electrification in which certain materials become electrically charged when they are brought into contact with a different material and then separated. One of the materials acquires a positive charge, and the other acquires an equal negative charge. The polarity and strength of the charges produced differ according to the materials, surface roughness, temperature, strain, and other properties. Amber, for example, can acquire an electric charge by friction with a material like wool. This property, first recorded by Thales of Miletus, was the first electrical phenomenon investigated by humans. Other examples of materials that can acquire a significant charge when rubbed together include glass rubbed with silk, and hard rubber rubbed with fur.
But although predictions could be made, (Coulomb's Law, Gauss's Law) etc, it was not until Faraday and Maxwell managed to link electricity and magnetic effects together than that substantial progress on the causes of electricity, which I would define here as the flow of current, especially the sustained controlled flow, was made.
I would concentrate on the year 1832, when Michael Faraday published the results of his experiments. You have to remember, that up to and beyond the 1900's, the atomic nature of matter was not accepted by many eminent physicists, including Max Planck. It was the experiments of Rutherford and others that started to convince mainstream physics of the existence and possible structure of an atom composed of an atomic nucleus with an (arbitrary assignment of positive charge), and an electron, taken as having negative charge.
In 1897, the electron itself was discovered:
SOURCE Nobelprize.org
Towards the end of the 19th century Joseph J.Thomson (1856-1940) was studying electric discharges at the well-known Cavendish laboratory in Cambridge, England. Several people had been studying the intriguing effects in electric discharge tubes before him. Spectacular glows could be observed when a high voltage was applied in a gas volume at low pressure. It was known that the discharge and the glow in the gas were due to something coming from the cathode, the negative pole of the applied high voltage. Thomson made a series of experiments to study the properties of the rays coming from the cathode. He observed that the cathode rays were deflected by both electric and magnetic fields - they were obviously electrically charged. By carefully measuring how the cathode rays were deflected by electric and magnetic fields, Thomson was able to determine the ratio between the electric charge (e) and the mass (m) of the rays. Thomson's result was $e/m = 1.8 10^-{11} $ coulombs/kg.