Someone on the radio, discussing Twitter abuse cases like this one, seemed to think that the thing that made a message illegal was being “menacing”. But the law is broader than that; from the Malicious Communications Act 1988:
(1) Any person who sends to another person—
(a) a letter, electronic communication or article of any description which conveys—
(i) a message which is indecent or grossly offensive;
(ii) a threat; or
(iii) information which is false and known or believed to be false by the sender; or
(b) any article or electronic communication which is, in whole or part, of an indecent or grossly offensive nature,
is guilty of an offence if his purpose, or one of his purposes, in sending it is that it should, so far as falling within paragraph (a) or (b) above, cause distress or anxiety to the recipient or to any other person to whom he intends that it or its contents or nature should be communicated.
I think that makes quite a lot of online unpleasantness illegal, although you wouldn’t know it from the scanty levels of enforcement.