The Ancient Greeks served some form of cake with candles to honor Artemis, the goddess who, among other things, had dominion over the Moon. As such, people offered cakes that were not only shaped like the celestial object, but decorated with lit candles, presumably to make it glow. It has also been reported that smoke from the candles was thought to help the goddess hear an individual’s prayers as it ascends to the heavens.
Persians and Romans are known to have celebrated the birthdays of at least some 'commoners', although it does not appear that the custom was as ubiquitous as it is today. Rather, when a wealthy person reached a major milestone like 50, family and friends might throw the person a party and serve a special cake. However, it does not appear that they put candles on the birthday cakes.
The Chinese have long had birthday celebrations, though eating cake on that day has only been a recent practice, adopted from the Western world. In China it is traditional to eat longevity noodles on one’s birthday.
German bakers during the 15th century, began marketing single-layer cakes for birthdays. By the end of the 18th century, the practice became common in the west. The Germans were also adding candles on the birthday cakes, numbering at least the years the child had been alive plus often more in the hope of a long life to come.
During 1746 Count Nikolaus Ludwig von Zinzendorf had “a cake as large as any oven could be found to bake it, and holes made in the cake according to the years of his age, every one having a candle stuck into it, and one in the middle.”
It wasn’t until the end of the 19th century that ordinary people had sufficient funds and ingredients were cheap enough, that the masses began incorporating enriched, frosted birthday cakes as part of a birthday celebration.