A sand filter or "bacteria bed" is a layer of sand that is used to clean the water of bacteria and other microorganisms. It is a type of filter.
A layer of sand or gravel is used when sewage goes through sewage treatment. Before sewage comes to the bacteria bed, it should already have gone through part of the sewage treatment. At the bacteria bed, sewage gets exposed to (or has contact with) air, while microorganisms make some change to that sewage. The oxygen in the water kills the microbes, which are anaerobic.