It blocks strong signals outside the receive channel which can overload following amplifier and mixer stages.
The roofing filter is usually found after the first receiver mixer (which normally contains an amplifier) to limit the first intermediate frequency (IF) stage's passband.
It prevents overloading later amplifier stages, which would cause nonlinearity ("distortion") or clipping ("buzz") even if the overload occurred on frequencies whose signal is not heard directly.
For more demanding uses like listening to weak CW or SSB signals, a roofing filter is required that gives a smaller passband appropriate to the mode of the received signal.
These narrow filters require that the receiver uses a first IF well below VHF range, perhaps 9 or 11 MHz.