Why is light affected by gravity even though it is massless? Why is light affected by gravity even though it is massless?
 A: The important clarification is that objects with energy is affected by space time curvature which is gravity. This obviously includes massive objects as mass is equivalent to energy. 
Also, notice the equation $E=mc^2$ is only a special case of the original relativistic energy-momentum relation equation when the object has zero momentum, that is - its velocity is zero: $$E^2=(mc^2)^2+(pc)^2$$
Where $p$ is momentum so when a non zero rest mass object is at rest, $p=0$ and it simplifies to $E=mc^2$. 
Now, for photons/light they have zero rest mass($m=0$) but they do have a value for momentum. So thus then the energy of a photon from the equation becomes:
$$E=pc$$
So then the correct relation comes like:
$$E=hf=pc$$
$$p=\frac{hf}{c}$$
Thus,
So finally we can say that the photon can have energy even though it does not have mass, because it has momentum. Thus it is in reality that objects with energy are influenced by space-time curvature. So since light has energy(so it has momentum) so it's effected by spacetime curvature.
