Given: The speed of light in space is a constant; it does not vary (proven).
Given: Time near a large mass (e.g. Earth) is slower than time further away from a large mass (proven).
Given: velocity = distance traveled / measured time.
Therefore distance traveled by light must change with a change in measured time.
This alteration of the "metric" of space as well as time (call it spacetime) is what we call GRAVITY.
The "metric" can be thought of as a 3-dimensional grid overlying space. This grid is the measure of distance in space.
Mass causes this alteration of spacetime somehow, and is affected by it (we call it "gravity").
Mass obviously wants to move to where time is slower and the "metric" of space is smaller.
A clock on a GPS satellite is about 500 picoseconds faster per second than a clock on Earth (the Special Relativity effect of the satellite's velocity through space is removed from this time). That's 1/50,000,000,000th of a second. The speed of light is about 300,000 meters per second. So the linear change in the "metric" of space on Earth will be about 300,000/50,000,000,000 of the linear distance of the "metric" of space at the GPS satellite orbit or 3/500,000 meters or 0.000006 meters smaller. See Time Dilation/Gravitational Time Dilation on Wikipedia.
Electromagnetic waves (photons) bend closer to a large mass as they travel through space because they have energy, and Einstein's General Theory of Relativity formula includes energy in its stress-energy-momentum tensor. The General Theory of Relativity explains how spacetime causes gravity in extremely complex mathematical terms. Einstein used the term spacetime because he combined the 3 dimensions of space with time to come up with his mathematical formula. Since he characterized spacetime as 4-dimensional, he said that spacetime "curves" more nearer a large mass. This is equivalent to saying the "metric" of space get smaller while time slows near a large mass. Either visualization works.
Astronomer Edwin Hubble famously postulated in 1929 that only the continuing expansion of [the "metric" of] space could account for the fact that the further that light had to travel from distant stars/galaxies, the greater the red-shift of light (Hubble's Law). Red-shift refers to the fact that even though light always travels at a constant velocity, its energy (measured by its wavelength or frequency) decreases as space expands. It's also true that light is red-shifted as it travels away from a large mass (like Earth), or blue-shifted as it travels closer to a large mass.
You can visualize light being red-shifted with space expansion by imagining a string in the form of a sine wave beginning at point A and ending at point B. If you move point B further from point A (space expanding), the sine wave will have a longer wavelength, which, if the sine wave represented a color, would change in the direction of the red end of the color spectrum.
Astrophysicists don't like to guess at what caused the Big Bang and Inflation, but the General Theory of Relativity seems to play a part in Inflation. An absence of mass would cause space and time to expand (Inflation). How fast it expanded wouldn't matter as long as space and time changed together so as to keep the speed of light constant. This explains how Inflation seemed to greatly exceed the speed of light. And, once mass began coming into existence, the expansion of space and time would begin slowing (which is what happened). It would still be expanding, but at a slower rate nearer mass, and it's been shown to have stopped expanding near a large enough amount of mass, like a dense galaxy.
Magnetism is very similar to gravity, but it needs a moving electrical charge, along with the Special Theory of Relativity, to exist (electrical charges travel VERY fast). Relative motion at relativistic speeds causes an "apparent" change in positive/negative charge (number of electrons vs. protons "seen" at any one time). Permanent magnets exist because all the electrons in a permanent magnet are oriented in the same direction, i.e. their electrical charges are all "spinning" in the same direction (VERY fast). I quotize spinning because physicists prefer to think that they simply have angular momentum, and use the term spin in a different way. So magnetism is simply the name given to how VERY fast moving or "spinning" electrons along with the Special Theory of Relativity affect other electrons. In this way, it's like the term "gravity."