The idea that photons, which are particles of light, have zero mass is a fundamental concept in physics. According to the theory of general relativity, gravity is not simply a force acting between objects with mass, but rather a curvature of spacetime caused by the presence of mass and energy. All forms of energy, including photons, contribute to the curvature of spacetime and, therefore, are subject to the effects of gravity.
Although photons have no rest mass, they do possess energy and momentum due to their motion and frequency. In the presence of a gravitational field, such as that created by a massive object like a star or a black hole, the path of a photon will be curved as it travels through the curved spacetime. This bending of light is commonly observed and verified, such as during the gravitational lensing phenomenon.
In a sense, we can say that photons "feel" the effects of gravity because they follow the curvature of spacetime caused by massive objects, even though they themselves have no mass. This phenomenon is a consequence of the intricate interplay between gravity and the nature of spacetime described by general relativity.