Serve Someone Right Meaning

(idiomatic, Of an unpleasant event) To happen to someone who is thought to deserve it.

Example: Used other than as an idiom: see serve,‎ right.
  If my memory serves me right, we had a similar discussion a few months ago.
1852 -- Harriet Beecher Stowe: Uncle Tom's Cabin (Chapter XVIII)
  "And they counts my money and tickets, when I gets home, to see if I's got the change; and if I han't they half kills me."
  "And serves you right," said Jane, the pert chambermaid, "if you will take their money to get drunk on."