It was not until Einstein and his General Relativity Theory that anyone thought that gravity could affect light.
Previously, Isaac Newton’s theory was that an object had to have mass to be affected by gravity. Since light does not have mass, under newtonian physics, it would be unaffected by the gravitational pull of an object.
We now know that light’s trajectory can be altered by gravity. According to Einstein’s theory, any object with mass alters the shape of space-time. Anything moving through the fabric of the universe, such as light, will follow the curves already created by the objects warping space-time.You can find a quick rundown here
A popular example to help visualize how four dimensional space-time works is to imagine putting objects on a stretched out rubber sheet. The objects on the sheet push down and create curves in the sheet that are like the curves created by massive objects in space-time.
The reason that nobody, until Einstein, noticed that light can be curved by gravity is that it is very hard to observe. Light moves exceedingly fast. In order for an object to affect light’s trajectory in any way that we can observe, the object creating the gravitational pull has to be truly enormous.