If you're asking why doesn't the light emitted by the Sun simply fall back into the Sun, it's for the same reason I can build a rocket ship so powerful that it can fly out of the solar system and away from the pull of the Earth. The gravitational pull (or really, the curvature of spacetime) isn't enough to bring a photon back into it. You need something far more massive and compact like a black hole. What the Sun can do is only really bend light passing by slightly.
Through the same process. Something needs to be going rather slowly or be very close to an object like the Sun to be caught in an orbit. The Earth is moving very slow compared to something like light.
Light, even if emitted directly off the surface of the Sun, is just going way too fast to be pulled in by the Sun.