I'm going to give a longer, slightly less accurate answer because this is a fun question.
I'll start with special relativity because it's easier to understand.
Using a thought experiment the velocity and time dilation relation is not that hard to see and to calculate it, just use Pythagoras. A photon bouncing between two mirrors can be used as a kind of clock. In a moving ship, the photon appears to move straight back and forth or up and down, but to a person watching the ship fly past, the photon is moving in a V, at an angle, so it travels a longer path. Different distances from different observers, if we are required to use a fixed speed of light, those difference in distances correspond to time dilation.
This is explained fairly often. A few links below or just google "light clock spaceship"
Light Clock Wikipedia
Light clock proof
Light clock youtube video
Source of image above.
As noted in the other answers, this tells us what happens but it doesn't tell us how it happens. We accept certain rules either by observation or by calculation. The fixed speed of light is one of those rules, usually called a law in science. It's something scientists have known, or perhaps I should say, reluctantly accepted, since Michelson-Morley. Not long after (or was it before?), the Maxwell-Heaviside equations also worked out a constant speed of light by calculation, so we reached the conclusion of a constant speed of light by two separate methods.
Perhaps if you work out the Maxwell-Heaviside equations yourself, maybe you can kind of get an answer to how the constant speed of light can be explained. I'm honestly not sure. Those equations are a little above my paygrade.
But the fixed speed of light does lead us to variable time. Still not an answer on why or how, but there is a logical correlation between "if this is so, then that is so". So, if I tweek your question a little bit, we might ask, what is the logical correlation for gravity slowing down time because it still seems to stand out as one of those, how do you get there from here problems, even if you can see the spaceship light-clock problem, gravity is harder to picture. We also run into some heavy math, so it's not as neat or easy to explain.
When we do the light clock thought experiment with gravity, or, because gravity is hard to visualize, lets use gravity's nicer twin, acceleration, because we know what that is. Just step on the pedal and . . . it feels like gravity into the seat.
Einstein used an elevator for this thought experiment.
Imagine Einstein's elevator has a flashlight on one side that sends a single photon perfectly perpendicular to the other side. The elevator is not only moving but also accelerating, and I realize elevators don't perform constant acceleration but we're pretending that they do. The accelerating elevator means the perpendicular ray of light curves with respect to the person in the elevator, falling downwards but not in a line like the observer sees in the space ship, but a curve. And because it's curving, for the back and forth we'll need to turn the mirrors upwards a bit, so the light reflects off them and returns to the starting point - replaced with a mirror so it goes back and forth in an arc.
The curve pictured below.
What's interesting here is, the person observing from a stationary object sees the light move in a straight line but the person in the accelerating elevator sees the light curve.
Now, you might think, but the person in the elevator knows he's accelerating, so he can work out the math subtracting his acceleration and the light is really going straight. Well, except he doesn't know if he's accelerating. That was Einstein's argument. He has no way of knowing if he's in an accelerating elevator or an elevator suspended over a massive object and not accelerating at all, just suspended in a gravitational field. The gravitational field and the constant acceleration do the same thing to the photon. So, the photon follows a curved path or a straight path. That is, either the photon is being curved by gravity or the space ship is accelerating giving the photon the appearance of curving because the ship is moving. Both calculations are valid.
What's always true is that the light is going straight through curved space time and light travels at a constant speed, so different distance traveled reveals time-dilation. This gets a little hard to picture with both acceleration and velocity and it works out to some pretty tricky math called tensors, which are hard to understand unless you're David Hilbert or equivalent, but you have a curved or a straight ray of light depending on your point of view. You have light traveling different distances and that implies different time dilations. Now, maybe I got something wrong in there, but that's kind of the idea that light travels different distances based on the observation which implies different rates of time.
If you don't like that one, a more common experiment is what happens to the light moving against the gravitational field. A well known example of this is the Harvard Tower experiment also known as the Pound-Rebka experiment. Some people, perhaps most people find that explanation easier to follow. I like the light clock in an elevator personally.
I'm not sure that's a good answer, but I wanted to go a bit into the mechanism behind the very real and well observed and measured gravitational time dilation and give you a little more of an answer than "we don't know", which is technically a good and correct answer, but I wanted to go a bit beyond that.