Everyone knows that baseball is full of unwritten rules and if you break one of these rules then you are probably going to get thrown at in your next at bat. This mentality and approach to the game are dangerous and it discourages fun, to an extent. So then when is it alright, if ever, to throw at a batter?
In some scenarios, throwing at a batter is almost expected afterward. A hard slide into second to break up a double play or a huge collision at the plate can badly injure the players involved, as well as upset the defensive team. This is a situation where throwing at a batter is expected because someone made a reckless play that put one of your teammates in danger. The lines here can get blurry because you can never be sure if there is malicious intent or not in these usually very quick plays.
Another situation where it can almost be expected is when a hitter pimps a home run. This is where I think that throwing at the batter is uncalled for. In that situation, the batter won the matchup and should be able to celebrate accordingly, if he launches a ball out of the stadium then he should be allowed to take his time around the base paths. Having to respect the pitcher, who is probably celebrating strikeouts, is just ridiculous. Hitters pimping home runs will always be fun to watch and they should not be punished by another player for it.
What it comes down to is that most things can be solved without throwing at a batter. There is usually no need to put a hitter in danger of being injured just because you are mad at him. Do I understand why it happens sometimes? Absolutely. Do I think that pitchers need to cool it a little bit? Absolutely.