Creating light isn't awfully hard biologically - there are lots of reactions that can create (mostly monochromatic) light. Even humans make tiny yet detectable amounts of light as a side effect of some cellular level chemical reactions.
It does use quite a lot of energy, but illumination to levels similar to moonlight is still tiny compared to the energy budgets of most animals, even if the biological light-making process is pretty inefficient.