The primary purpose of wax is to sustain the candle flame.
Essentially, all wax constitutes of hydrocarbons. When we light the candle wick, the heat generated melts the wax and eventually breaks it down to Hydrogen and Carbon. These vapors are drawn to the candle flame, which react with oxygen to produce water, carbon-dioxide and most importantly, heat and light. So what happens to the candle wax? It is consumed, slowly, to produce the heat and light that characterizes a candle.
Pictured above: An innocent candle is burnt alive, slowly, as its friends watch helplessly. Their end would be similar, sadly.
To increase the efficiency of the candle, the wax can be altered. It is the wax that determines the quality of the candle.
For example, most commercial candles have Paraffin wax. Being a by-product of fossil fuel, the flame would produce unhealthy fumes, although not entirely toxic. It is also the cheapest. A healthier alternative is Beeswax, which is made from the wax bees produce. Beeswax produces a cleaner flame, and since honey is closely associated with it, it gives off a better fragrance. For obvious reasons, it is costly. There are others, including Palm wax, Soy wax, etc.
A very bad example of wax material would be earwax. Earwax is secreted in the ear for cleansing purposes, and if used for candle making, it would create very bad results. It cannot sustain the candle flame as it has inconsistent materials in it, like dead skin cells, dust, etc. As a result, the candle flame would pop and flicker irregularly. And as opposed to Beeswax, that gives off a sweet smell, the smell from earwax candles would be nasty. That's why you don't find earwax candles anywhere.