A basic introduction to natural filtering of water can be found on-line at the USGS "Water Science for Schools" website. The address for the site's ground-water-quality page is:
Natural filtering is a big topic. Some filtering takes place when water flows over the ground, such as when muddy water from a plowed field or a construction site flows through grass or weeds on its way to a stream. Some of the mud is filtered out. In addition, some filtering takes place when the water is in lakes or streams, through the actions of plants and bottom-dwelling animals (like freshwater clams and mussels) that take in water, remove nutrients, and put it out again. Here's a page that talks about filtering in wetlands:
Here's another, longer, but very good piece about wetlands. The part about natural filtering is in the section called "maintenance of water quality":
A lot of filtering takes place in the uppermost layer of sediment at the bottom of a lake or stream. This is called the hyporheic zone, and it's full of bacteria and other microorganisms that bring about chemical changes in the water. Here are a couple of web pages with more information about the hyporheic zone:
Finally, a lot of filtering takes place as water moves through the ground, through soil, the unsaturated zone (where both water and air fill the pore spaces, or spaces between soil particles), and in aquifers (where water alone fills the pore spaces). Large particles, such as silt, leaves, and twigs are filtered out because they can't fit through the small pore spaces. Smaller particles such as suspended clay and microorganisms become adsorbed (get stuck) onto soil particles. Some microorganisms are eaten by other organisms. And some dissolved chemicals such as nitrates and pesticides are taken up by bacteria that live underground. This doesn't mean that all chemical or microbiological pollutants are filtered out of ground water–untreated ground water can in some cases contain harmful pollutants. But ground water is usually cleaner than surface water. The natural filtering process that removes pollutants from ground water is sometimes called "natural attenuation". Here is a web page about a report on the topic:
Some cities use the natural filtering ability of aquifers as a way to help treat their public water supplies. They put large wells along the banks of a river, or even under the bottom of the river. The river water flows through the ground on the way to the well, and undergoes some filtration in the hyporheic zone and the aquifer, on the way to the well. This is called riverbank filtration. Many European cities have been using riverbank filtration for 50 years or more, and it is becoming popular in this country, as well, in places like Cincinnati, Ohio; Lincoln, Nebraska; Louisville, Kentucky; and Parkersburg, West Virginia.
There are even some cities where clean natural water is so scarce that treated sewage is reused by filtering it through the ground.