In most cases, bioluminescence is useful for:

attracting prey

producing oxygen

supporting plant life

navigating dark waters