Blue animals in the ocean live near the surface. Deeper down, animals are blue on top and white on the bottom. At greater depths, animals are generally transparent, but have red stomachs. Below that, animals are red or black over their entire bodies. Finally, at the bottom, almost all animals are either a pale red or a cream color. The most likely explanation for this distribution is camouflage (color that blends in with the surroundings).
For an animal to be invisible, its color and brightness have to match that of the background. Unfortunately for the animal, its color also depends on the light hitting it. For example, a white piece of paper looks red under red light, and blue under blue light. In our normal day, the changes in the color of the surrounding light have a big effect on the color of the objects we see.
So an animal that relies on color for camouflage has to worry both about the color of the background and the color of the surrounding light. For animals living on the seafloor, the background and the animal are illuminated by the same light, so the animal doesn't have an issue. Animals swimming in the water do, though, because the background light isn't affected by the surrounding light in a simple way. Scientists are still learning about the "tricks" that marine animals use to camouflage themselvers.