Filtering is a process of selecting, or suppressing, certain frequency components of a signal.
A coffee filter allows small particles to pass while trapping the larger grains. A digital filter does a similar thing, but with more subtlety. The digital filter allows to pass certain frequency components of the signal: in this it is similar to the coffee filter, with frequency standing in for particle size. But the digital filter can be more subtle than simply trapping or allowing through: it can attenuate, or suppress, each frequency components by a desired amount. This allows a digital filter to shape the frequency spectrum of the signal.
Filtering is often, though not always, done to suppress noise. It depends on the signal's frequency spectrum being different from that of the noise:
The diagram shows how how a noisy sine wave viewed as a time domain signal cannot be clearly distinguished from the noise. But when viewed as a frequency spectrum, the sine wave shows as a single clear peak while the noise power is spread over a broad frequency spectrum.
By selecting only frequency components that are present in the signal, the noise can be selectively suppressed:
The diagram shows how a noisy sine wave may be 'cleaned up' by selecting only a range of frequencies that include signal frequency components but exclude much of the noise: