It is actually the accumulation of electrical charges on surface of a material, which is probably a nonconductor of electricity. As there is no flow of charge, it is known as 'static'.
This usually involves two materials, one having excess of (+) electrons, and the other having excess of (-) electrons. This happens when these materials are pulled apart, or rubbed together.
Electricity produced by friction caused by pressing or rubbing of two objects against each other, leads to triboelectric effect, where the electrons from surface of one material are transferred on the other.
Hence, the one losing electrons will have excess of (+) charge, and the one who gains will have excess of (-) charge. Attraction, repulsion, sparks, or shocks are caused due to the buildup of electric charge due to friction.
How to Get Rid of Static Electricity
Another way is using a hair lotion, hairspray, gel or mousse on your hair. Make sure you take it on your palm, and then apply it over hair, not over the roots and scalp. One of the ways to eliminate it from hair brush is to spray some water or hair spray on it. You can also wipe it with a dryer sheet available at general stores.
You must keep your hair, and the hair brush clean. Usually blow drying will lead to problem of flyaway hair, so if possible keep hair slightly damp.
All you need to do is use a fabric softener. Use a fabric softener for the last rinse, and wring cycle in your washing machine. Use dryer sheets to prevent static charge in clothes, especially woolen, nylon, and polyester clothes. You can place these sheets inside the sweater, or any outfits or garment bag.
Dry skin can make clothes cling to your body, so apply a moisturizer. During last wash cycle, put ½ cup of vinegar or borax in the machine. Using outfits made of natural fabrics is the best idea, these don't have much problem like that in case of synthetics. Synthetic clothing usually clings to body, so wear a cotton layer in between your body and clothing.
To make your house static-proof, just opt for things that prevent the build-up of static charges. Using natural materials, humidifiers and skipping use of synthetic materials is helpful. Keep dryer sheets handy to avoid that irritating cling.