To understand how light is affected by gravity, it helps to think of light as energy. So let's ask a basic question: when it come to light, what is energy?
By the Planck-Einstein relation, we know $$E = h \nu$$ where $\nu$ is the frequency of the light and $h$ is Planck's constant. So when we talk about the energy of light, keep that in mind. Also note different wavelengths of light have different frequencies, but all light moves at the same speed $c$.
Now consider mass-energy equivalence $$E^2 = c^2p^2 +m_0^2c^4$$
From this relationship, you can see that the mass term could be zero and yet $E$ nonzero given nonzero $p$. And this is the case for light. Light has no mass but it does have momentum. Note, we could also have an object with zero momentum and nonzero mass, which would also yield nonzero $E$.
So why does gravity affect light?
Einstein proposed a set of equations called the Einstein Field Equations that related spacetime curvature to the presence of momentum energy. He called the theory of General Relativity. General relativity says, given a distribution of momentum energy (e.g. a syphericslly symmetric non-rotating charge free mass distribution) we can calculate the spacetime curvature. So, one example would be the sun. The sun induces curvature (ie gravity) because mass is equivalent to energy. And so the sun's momentum-energy curves spacetime. But light too is energy and so it too is affected by and affects spacetime curvature.
What is spacetime? Well, you know both space and time can be measured with numbers. For instance, I can run a mile in 5 minutes. So that's a number representing amounts of time. I can also use numbers to represent space. For instance, a basketball hoop is 10ft tall. Spacetime is just a way of relating the numbers of time and numbers of space in such a way that we establish information their relationship. This is a brief intuition of what Einstein's special relativity is all about.
What does it mean for spacetime to be curved? The basic insight comes from geometry. In our everyday world, we observe straight lines. But when these spaces "curve", suddenly the relationship between our straight lines is altered so that the geometry behaves very differently. You can read more about it here