If we are talking games, i think it's similar to the bully mentality. They like the reaction of others feeling powerless.
If we are talking in general, for black hats, it either for monetary gain or similar to above. You need to watch Black Mirror and the episode about the kid that gets recorded jerking off and blackmailed.
For white hats, there is also monetary gain, but I think these types of people really just want to help and prevent people from being taken advantage of.