Comes from the root word, Giveus Hellus, which is Latin for, "Fuck that shit up, Polonius!"
Since hell is a bad place full of suffering, to give someone hell is to create your own little part of it just for them.
It can also be a term for teasing or general razzing, ("he was really giving you hell at the party, wasn't he?") as well as winning in an athletic event. "We really gave that team hell."