If you want to keep your fish healthy, then you 100% need to keep your aquarium filter on at all times, 24/7. So you should ideally have it running at all times, and only turn it off when strictly necessary.
Lights, air pumps, and some other items of the aquarium, although also important, can be turned off now and then without causing any damage. But the aquarium filter being off for too long can cause some serious damage to the fish.
However, this does not mean that your fish will instantly die if you turn the filter off. In fact, there are types of aquariums that don’t use filters (although that is because they require a different and more intense type of care).
Your fish can survive having the filter turned off for a few hours at a time. What the filter does, is keep the water clean at a certain level. So turning it off can cause the aquarium to become dirty, and can cause the beneficial bacteria to die, and harmful bacteria to thrive.
So although you can, in fact, turn off the filter, it is recommended that you don’t. And if you have to turn it on for any important reason, make sure the filter isn’t off for more than a few hours, as after that damage to the fish can occur.