According to the theory of general relativity, mass and energy curve or warp the fabric of spacetime. This curvature of spacetime is what we perceive as gravity.
In Einstein's theory, mass and energy are not separate entities but are unified as a single concept called "mass-energy." Mass and energy tell spacetime how to curve, and curved spacetime tells mass and energy how to move. The presence of mass or energy causes a distortion in the fabric of spacetime, similar to how placing a heavy object on a stretched rubber sheet would cause it to bend or curve.
The curvature of spacetime determines the paths that objects, including light, follow. Objects move along what is known as geodesics, which are the paths of least resistance in curved spacetime. These geodesics are what we perceive as the effects of gravity.
So, to summarize, mass and energy warp spacetime in general relativity because they create a curvature in the fabric of spacetime, and this curvature determines the motion of objects and the effects we observe as gravity.