If you've ever been in a competition with someone else, chances are you've engaged in some trash talk. It doesn't even have to be related to sports. Trying to reach a goal at work before your coworkers? Trash talk. Persuading someone to take a shot with you at the bar? Trash talk.
In some cases, it can be in jest, but in others, it's meant to get under your "opponent's" skin. If you get in their head a little bit and throw them off their game, it's a little bonus that goes in your favor. You're trying to gain an edge over the opposition by any means possible.