The basic meaning is to be hostile under the cover of friendliness. The word's origin is Greek, "sarcasmus", see sarchasaristic (Hobson 2018). However, it usually comes with a cue which helps the receiver to understand it. For example, a mother saying "Oh, that's clever!" when a child makes a mistake always signals her love with her tone of voice. Quite different when a hostile person says "Oh, here comes Mr Clever-clogs!". So a person learns how to decode the message.