A common advice on dealing with malicious users is:
Do not feed the troll!
What does this mean, what is the rationale behind this, and are there any exceptions?
Because the primary purpose of a troll is, well, to troll: to feed you inflammatory remarks that you react to.
That is their only goal*. They are not interested in the content of your reactions other than as material to further trigger you with.
In short, trolls are bullies.
Since that is their only goal, no (type of) reaction from your side is going to change their behavior. Only when they are forced (e.g. their communication channel is blocked) or get bored, will they stop. This leaves you with two courses of action: ask others (like a website moderator) to block them, or ignore them.
There are stories of people reacting in other ways and get the trolls to stop, but those are the exceptions. Do not expect that you can outwit them, especially when several of them band together.
Even when you have the technology to attack them back, success is not guaranteed beforehand, and you must seriously ask yourself if you want to take that trouble and risk.
When you are the victim of a troll, what there is to learn is to not care. You can only learn/teach yourself how to deal with them, there is nothing you can change with them.
BTW. Not everyone agrees with what I write here, but I think it is the general consensus.
Two interesting PBS Channel episodes about 'Are there different kinds of trolling?':
The Experience of Being Trolled (22 Jan 2014)
When Is A Troll No Longer A Troll? (21 Sep 2016)
and a TED Talk by Whitney Philips: Why study villains, scoundrels, and rule breakers?
And to sum it all up: Glove and Boots.
* Some (like 'Ken M') do it as an art form. But that's not what you were talking about.
I would suggest that you're asking the wrong question. Once you "get" the whole troll thing, it's obvious not to feed them. What isn't obvious, especially to those who haven't met trolls before, is that arguing with them (a common response when someone is wrong on the internet) feeds them.
So we have this sequence:
The real answer to "why should trolls not be fed" is an explanation of what trolls enjoy, and why they post what they do. Once you successfully get that across to the person who was feeding them, they will naturally stop feeding them. The hard part is
that sensible, earnest, useful thing you're doing? The same thing that has served this community well in the past? You need to not do that for this user because this particular user is a troll and your earnest corrections are just food for the nasty behavior.
It's a lesson that typically takes several tries to learn.
While I agree with the top answers, I'd like to point your attention to the different kinds of trolls.
Your reaction may for example depend on whether the person only made one "trolling" comment. I believe in that case it is better to react by giving your perspective. In this case "not feeding the troll" means not giving them more room for further trolling by remaining calm and avoiding controversial/aggressive statements.
If on the other hand you have a "serial-troll" someone who trolls repeatedly, I agree with Jan Doggen, that you are better of just completely ignoring them.
I think occasionally its important to feed a potential troll to check whether they are really trolls or not.
The term "troll" originated from fishing, bait is attached to one or more hooks which are dragged behind the boat in the hopes that the fish will "take the bait".
It became an internet term to describe a person who would "troll" a forum waiting for someone to take the "flame bait". It then quickly morphed to become a person who trolled. A "Troll" became a term as one who posted for reactions. It soon became synonymous with the term "griefer", though a "griefer" is specific to online gaming as one who is there to cause grief and ruin everyone's good time, rather than play.
Once the term "Troll" became a noun, it merged into the old meaning of a malicious monster known for a voracious appetite and general malice. Telling people to ignore him/her and not to take the bait quickly became "PDFTT" one the Usenet, which is an abbreviation for "Please don't feed the troll".
What people mean by "PDFTT" is to not give them the attention or reaction they desire. It has been proven to be the only effective way of dealing with trolls. On the Usenet, before there were ignore buttons, the typical reaction would be to call what was termed a Passive Ignore Simultaneous Strike, where everyone would simultaneously ignore the troll. This was the most effective way to deal with someone as they either reformed or went away.
The Passive Ignore is not used these days thanks to ignore buttons and stronger moderating, but the warning to not feed the troll remains.
Trolls are attention seekers/lowlives who have little to do so they go around insulting users and other things as such. Not acknowledging their short Internet lives will make the troll go away and not get this attention they so crave.
All they want to do is cause trouble and provoke other users, getting the reaction from the users they pick on.