Earwax (also known by the medical term cerumen) is not really wax. Earwax begins as a combination of substances secreted by a combination of sebaceous glands and sweat glands in the ear canal, known collectively as the ceruminous glands. In its final form it is a mixture of dead skin (~60%), oily secretions such as sebum and squalene (~20%), alcohols (~10%), and cholesterol (~10%).
Many people view earwax as something dirty and unwanted, but ironically the purpose of earwax is actually to clean the ear canal and improve hearing. Natural jaw movements push the earwax outward along the ear canal in a conveyor belt-like process. Along the way, the earwax picks up and carries away any dirt, dust, and dead skin that have accumulated in the canal and would impair hearing if allowed to continue to accumulate.
Earwax also has significant antibacterial properties and laboratory studies have conclusively demonstrated that exposure to human earwax can kill a wide variety of harmful microbes.
Because earwax is natural and aids healthy function of the ear, most doctors strongly recommend against prematurely removing earwax from inside the ear canal. However, in some cases, impacted earwax can become painful and interfere with normal hearing, making removal a necessity. In many cases, impacted earwax is actually caused by the overzealous use of Q-tips in misguided attempts to remove earwax, which actually pushes some of the earwax deeper into the ear canal.