If you have ever had an instance where you feel a sudden shock when you touch something or your hair stands on end, that is an example of static electricity. This is a form of magnetism that is usually caused when certain kinds of materials are rubbed against each other, like plastic against wool, or the soles of shoes on a carpet. Rubbing causes electrons to be pulled from the surface of one item and deposited on the surface of the other. The more rubbing, the more electrons move, and the larger the static charge that builds up. The object that loses the electrons ends up having too many positive charges while the ones gaining it have too many negative charges on its surface area. The ensuing small shock is usually quite harmless but it can be a bit unnerving if not understood and the place to begin is in appreciating the nature of objects.
All matter in our world, everything which surrounds us, is composed of invisible units called atoms. Every atom appears like an empty space but it actually has three parts to it: the centre which is called a ‘nucleus’ which also contains two tiny particles called protons (which are positively charged) and neutrons (that have no charge, hence why they are neutral). Orbiting around the nucleus are even tinier particles called electrons that are negatively charged, the opposite of the protons. Protons, neutrons and electrons are very different from each other, having their own properties, or characteristics, and it is one of these properties that is called an electrical charge. The charge of one proton is equal in strength to the charge of one electron. When the number of protons in an atom equals the number of electrons, the atom itself has no overall charge, it becomes neutral. To get a better image of an atom is to imagine a simple solar system, with the negative electron particles constantly moving around the nucleus and its contents in orbiting waves.
Of course, with such a formation it stands to reason that everything around us will be made up of charges. The opposite charges in each object will attract each other while similar charges will repel one another. What makes an object neutral is that its positive and negative charges usually balance each other so we would not be affected by any of its electrical activity. However, static electricity occurs when there is an imbalance between the negative electron and positive proton charges in any item. These charges often build up on the surface of the object until they can be released, and that is usually through a circuit of some kind. Thus by rubbing two objects together the negative charges (electrons) are transferred through the circuit created by the rubbing.
You can also become a handy circuit in transferring static electricity. For example, if you were to rub your shoe on a carpet, your body would collect extra electrons which would cling to your body until you touch your pet, and then the transference of those electrons to the pet causes you to feel static electricity. The same with when your hair stands on end after you remove a hat. The electrons from the hat sticks to your hair and, as your hair would already have its own electrons, it would be repelling the new ones by separating each strand of hair from each other. Hence why your hair would stand on end in the process. it is simply trying to separate itself and causes static electricity at the same time as it repels the negative force.
In a nutshell, static electricity is simply the imbalance of positive and negative charges between two objects which then causes electrical activity as they try to repel each other. Static electricity is formed much better when the air is dry or there is low humidity. When the air is humid, water molecules can collect on the surface of various materials which then prevents the buildup of electrical charges.