Why use is camera ray in the world

In some instances, you want a colored environmental light, but a black background.

Making the background black, but only from the camera’s perspective is one way of doing that.