If you spend the night at the Coconut Forest in Piaui State, Brazil, you'll be able to see a rare species of fungus that glows in the dark. Although scientist already understand how they light up, they are still struggling to understand the reason why they do it and how that affects their ecosystem.
This article by National Geographic explains how the chemical process works:
To make light, you need three ingredients: oxygen, a luciferin, and a luciferase. A luciferin is any molecule that reacts with oxygen and in doing so emits energy in the form of a photon—a flash of light. A luciferase is a molecule that triggers the reaction between oxygen and the luciferin. In other words, the luciferin is the molecule that lights up, while the luciferase is what makes it happen.