Chances are, you've seen a sign on a fish tank somewhere specifically instructing observers not to tap on the tank. Tapping on a fish tank can scare the fish who live inside the tank, making it difficult or impossible for you to view them properly.
Fish Are Prey
Fish are prey animals who, in their natural environment, constantly have to worry about being eaten by larger animals. Fish generally do not have a lot of defensive capabilities when it comes to protecting themselves from predators, so they flee and hide when a threat or perceived threat occurs.
Fish exist solely in the world you have created for them. Your fish probably do not spend hours of their day looking at the world outside of the tank and they have a poor idea of the various places, people and pets who exist outside their tank. This means your fish will likely view anything outside the tank as a threat.
Tapping on a Tank
When people tap on the glass of a fish tank, the fish is most likely to believe the tapping and its resulting effect inside the aquarium are caused by some kind of predator, and they'll attempt to go into hiding. When your fish are fleeing or hiding in the depths of the tank to avoid the mysterious predator making the tapping noise, you cannot enjoy them.
Fish who are exposed to repeated tapping can become stressed and frightened. Stressed, frightened fish will probably spend most of their time hiding in the depths of your tank. They also tend to suffer from health problems as a result of the stress, which puts a strain on their overall condition. There is no good excuse for stressing out your fish by tapping on the glass of their tank.