This is either one of those urban myths or a misunderstood question. So, in this post I will answer both.
The Urban Myth
Many people incorrectly believe that tapping the charger on the rear tail light will help with charging speed or connectivity. There seems to be a myth that this will help with “aligning electrons” or removing static electricity. Or, perhaps more simply, to remove anything blocking the charging pins from connecting.
Obviously, except for in the most unusual circumstances where something is interfering with the charging connection (ice, dirt, random object), there is no reason to tap the charging cable against the car.

Opening The Tesla Charge Port
There are a number of ways to open the Tesla charging port and tapping or pushing on the cover is one of these ways. Because there is a spring-loaded flap over the charging port, you simply push it down to open it.
Perhaps some people have been seen tapping on the tail light, or near the tail light when they are about to charge. After all, the supercharger charge cable can open the charge port automatically or the cable has a button to help with opening too.
Either way, there might also be unusual uses of the cable that confuse people into thinking that this tapping is doing something useful.
My advice. Don’t bother tapping the charging cable against the car. It won’t speed up your charging!