Candles are a reference to the origins of Dr. Lunatic, SPISPOPD, where pumpkins had taken all of Earth's candles, and Bouapha had to get them back, in the same way as brains in Dr. Lunatic, being required to win the level.
Candles are not necessary to include in a level, but add extra challenge, as they are needed to achieve 100% on the world. Collecting a candle gives the player 5 points. When all the candles in a level are collected, a a little jingle is played and the player lights-up.