New research shows that bioluminescent bacteria use the glow to get eaten by shrimp; when the shrimp eat enough bacteria, the bioluminescence shows up in their gut, attracting fish. The fish eat the shrimp, swim around, then poop out the remnants and the bacteria, which are just fine after spending time in the digestive system of the shrimp and the fish. So this helps the bacteria move to new locations. Not only that, while they're in the guts of the shrimp and the fish, they eat some of the other stuff that's in there!
Research shows ocean bacteria glow to attract those that would eat them