Objects with mass in the universe create warping of spacetime. In these warped regions, time runs slower, especially as you get closer to the center of the mass responsible. Other objects of mass tend towards these areas of slower time. The higher the mass, and therefore the greater the warping of time, the more intensely those objects are attracted to that area. This effect is known as gravity. In black holes, where spacetime is incredibly warped, objects are pulled violently in. Around the Sun the effect is not as extreme and so the pull that its mass creates is balanced by the centrifugal force of the planets orbits, keeping them carefully spinning around.
This time distortion can be measured even on a much smaller and more local scale. An atomic clock was sent up to 10,000km on a rocket, and radio signals were used to compare it to a clock kept on the ground. It was found that time flows by about 30 microseconds slower on the ground than at that altitude.
Because of the time difference between Earth's surface and its atmosphere, orbiting satellites must compensate in order to send accurate data. At 20,000 feet, time runs faster by 40 microseconds per day. For GPS triangulation to work, where signals are bounced off three or more satellites and the transmission time is carefully recorded to pinpoint your location, the satellites must convert the reading to "surface time".
Additionally, radio signals were sent to the Voyager missions as they orbited Mars. There was a discrepancy here as well. It took more time than expected for the signals to bounce back when they crossed closer to the Sun. Because radio waves travel at a constant speed, the only explanation is that the amount of space that they had to cross was a longer distance than what traditional methods would predict. Signals that passed closer to the sun were warped more than signals traveling farther from it.
This is also related to a phenomenon called gravitational lensing, where large masses cause light to bend around them. This allows us to see distant celestial objects that would otherwise be too dim or obscured by other bodies in our line of sight. It also sometimes causes multiple images of the same object to appear, at different points in time because of the difference in the distances the light traveled. In the case of Einstein's Cross, four distinct images of a distant quasar can be seen. Because of the time difference, when it went supernova scientists were able to watch it unfold four times over, over a period of several days,
Because of the discovery of phenomena like this, we've come a long way in understanding what we're seeing when we look into the night sky, and how different forces in the universe affect each other.