Anonymity gives the impression that you can express whatever you like online, without being reprimanded for it. Online forums allow netizens to create screen names that are separate to their offline identity.
It is easier to type a mean comment on a screen than actually say it to somebody in person. Being surrounded by nasty comments in online settings can make us desensitized, which encourages people to make mean comments without getting into much trouble.
Sometimes, it's simply down to personality traits. Some people feel morally superior or feel that their opinion is the only one that matters.