Why does Saturn have both moons and rings? From my understanding, a ring can form around a planet when a moon gets too close to its Roche limit, and gets ripped appart by the planet's gravity pull. That makes sense to me, but I don't understand why Saturn has both moons and rings at the same place. 

I know the F ring is supposedly created by Enceladus' rejections, but I don't get why Pandora and Prometheus are not ripped appart as well as the ancient objects that formed the ring they are in. 

I couldn't find specific explanations for this. Does it have any link to the moon's density?
You're right that density is the important thing here. The Roche limit is the distance from the main body $d$ such that
$$d=1.26R_M\left(\frac{\rho_M}{\rho_m}\right)^{\frac{1}{3}}$$
where $_M$ denotes the main body and $_m$ denotes the satellite.

As you can see from the chart on the Wikipedia page, Pandora and Prometheus are both at least one and a half times the Roche limit from Saturn. Therefore, they're in no danger of being ripped apart any time soon.