Why does gravity affect time?
To the best of my understanding Gravity creates a curve in space time. This causes light to bend and since the velocity of light is a constant time must change because of the bending of space.
V = Velocity
D = Distance
T = Time
When gravity causes a curve in space time, the distance that light must travel increases. Since the Velocity of light is a constant then the time must slow down to keep the value of the speed of light the same.
Since Distance and Time are on the same side of equation the values of Distance and Time are inversely related. Therefore an increase in Distance must cause a decrease in time. The greater the gravity the greater the curving of space time and therefore the greater the increase in the distance light must travel around the curving space. This means the greater the gravity the slower the time.
Note using light years distance traveled by light to measure time is invalid as gravity affect the time. Theory says that if there is no gravity light experiences no time as as travels. A day is the same as 1000 years and 1000 years the same as a day. To regard time as a variable and velocity as a constant is counter intuitive to the human mind.