Most driving instructors will tell you not to tailgate other vehicles for several reasons. Following too closely is a factor in about 40% of collisions (in my state of Arizona), and they are not always minor in terms of injuries and fatalities. Following too closely often restricts your vision, making it likely your reaction time will be slower if something happens ahead. What is following too closely? If you are so close that you cannot stop without hitting something, that's too close! Many states define it just this way. Remember to use the two-second-plus rule to keep a good following distance.
What about when YOU are being tailgated? This is a dangerous situation for you as well. It is important to get the guy behind you "off your back." Here are some things to keep in mind.
First, when someone is tailgating you, add their following distance to yours. Simply put, follow the vehicle ahead of you no closer than 4 seconds (2+2=4) so that if you have to react, you've got the extra time and space to slow or stop without the tailgater hitting you. You've got to add his reaction time to yours, because you need the extra space.
Second, the best thing to do is get the tailgater safely around you. Do this by slowing slightly below the normal flow of traffic speed. This allows him more room to pass, and your slower speed makes it easier for him to do so. This is what you WANT. Think about the frame of mind of someone that is tailgating you. If not at first, very soon the tailgater gets impatient, frustrated, and maybe angry. Do you want him behind you, where you have no control over his actions? Tailgaters typically exercise poor judgment and endanger you and others trying to pass when it is not safe. If they still cannot pass after you've slowed a bit, then change lanes or pull off to the side and let them go by. For all of my testosterone-laden brothers out there, just let it go. Your lives are worth more than your egos.
Finally, here's what NOT to do. Don't hit the brakes suddenly, and do not tap your brake lights to warn the other driver to back off. Slamming on the brakes to get rid of a tailgater is against the law almost everywhere, not to mention that some folks get shot for doing it. You'd be irritating a person who is already angry, which is not too smart. Why make the other guy's problem your problem? Tapping your brake lights to get an impatient driver to back off is also not a good tactic. While not illegal (but check -- there may be exceptions), when you tap your brake lights without actually braking, you are crying "wolf." You are training the other driver not to take your brake lights seriously. Let's say you can't get the guy off your tail and he follows you for several blocks. If something requiring immediate response happens and you actually DO hit the brakes, the tailgater's reaction time may be longer because he is thinking you are just "tapping" your brake lights again -- and by tailgating he is already too close for comfort.
May your roads be smooth!