The stress-energy (of which matter density is a component) of a region of spacetime determines its curvature.
In empty space the metric, which tells us how to measure distances between events, is `ds^2 = dt^2 - (dx^2 + dy^2 + dz^2)`. Integrating this along a trajectory tells you the (square of the) proper time experienced by an observer traveling along it. As you can see, the further you move in space in a given amount of coordinate-time, the less proper time you experience: this is the source of time dilation in special relativity.
Around a spherical body of mass M, the metric is (in spherical coordinates, and ignoring some scale factors for convenience):
`ds^2 = (1-M/r)dt^2 - (1-M/r)^-1 (dr^2) - r^2 (dtheta^2 + sin(theta)^2 dphi^2)`
Compare to the flat space metric from before, now in spherical coordinates as well:
`ds^2 = dt^2 - dr^2 - r^2 (dtheta^2 + sin(theta)^2 dphi^2)`
So we pick up some additional time dilation as long as `M < r` (and it always is, unless you're in the interior of a black hole)