Styes are caused by bacteria from your skin (usually staphylococci bacteria) getting into the oil glands in your eyelids and causing irritation.
These bacteria, which are normally harmless on the skin of the eye, can become trapped on the edge of the eyelid with dead skin cells.
A swollen, red, and painful bump develops as a result, which can take a few days to heal. Read here- How to Get rid of a Stye Overnight