Even though it is pretty disgusting it does some good stuff. Ear wax is known more formally as cerumen. It is produced by glands in your ear called aprocine glands, which are also called ceruminious glands. You can think of them as like sweat glands.
Ear wax is made up of secretions from this gland along with pieces of dust, dead skin cells, hairs, and foreign bodes trapped in the ear canal (stuff that gets into your ears that’s not supposed to be there). There are two types of ear wax–dry and wet. Older people have drier, harder, more brittle ear wax, whereas kids usually have wetter ear wax (I bet this is more than you wanted to know). It seems that when cerumen is freshly secreted it has a semi-liquid form, but it gets harder over time, which may explain why, by the time, you notice it, it is hard, and perhaps crumbly.
As it travels from deep inside your ear canal to your outer ear, cerumen lines the ear canal, preventing your ears from being dry and itchy. That’s one of the good things it does. It also repels water and prevents insects from getting inside your ear. One scientist calls it “flypaper.” Lovely, huh? Some scientists also believe that ear wax has anti-fungal properties, meaning that it may prevent fungus and bacteria from developing in your ear canal.