Harry Potter and the Order of the Phoenix
by J.K. Rowling
Hagrid is the groundskeeper and Care of Magical Creatures instructor at Hogwarts. He is the loveliest person you can imagine: generous, kind, honest, and loyal. Hagrid is also pretty much Harry's first friend in the wizarding world: he was the one who came to find Harry and take him to Hogwarts for the first time in Book 1. So Hagrid has a special place in Harry's (and our) hearts. Which makes it all the more upsetting that Hagrid is missing from Hogwarts for the first two months of the school year. Wondering where he has gone doesn't exactly help Harry's bad temper, but it does build up suspense in the earlier parts of the novel.
Finally, Hagrid comes back from his mysterious trip. He is bruised and bloodied, but basically fine. Hagrid tells Harry, Ron, and Hermione what he has been doing: he has been on a mission from Professor Dumbledore to meet with the giants living in Europe. Hagrid is half-giant, which makes him a good candidate to act as liaison between the wizarding world and the giants. Professor Dumbledore worries that Voldemort will try to bring the giants over to his side, which is why it is so urgent that Hagrid go over to act as diplomat.
But unfortunately, Hagrid's mission doesn't go that well. He finds the giants all right, and he even gets along with the Gurg (their leader), Karkus, fairly well. That is, until Karkus is horribly murdered by the new Gurg, Golgomath. Once Golgomath gets to power, he won't listen to any of Hagrid's messages from Professor Dumbledore. Golgomath has already been won over by the Death Eaters. So Hagrid returns to Britain frustrated: he managed to get Professor Dumbledore's message of peace out to a few giants, but it's unclear how much of an effect he managed to have. What is more, the giants also tell Hagrid that his mother has died some years ago. So Hagrid really has quite a miserable summer. And this still doesn't explain why he's two months late for school – Madame Maxine, his travel companion, turned up at her school of Beauxbatons on time, after all!
You'd think, after such an exhausting mission, that Hagrid would be really glad to be back on the castle grounds. But even though he is home now, he keeps turning up with fresh bruises and bloody noses. And where was he for those extra two months? Harry, Ron, and Hermione can't figure out the answers to either of these questions, which generates more suspense for the second half of the novel.
These bruises, paired with Hagrid's generally wild appearance and huge height, do not do much to improve Professor Umbridge's opinion of him. Her horrible anti-halfblood prejudice means that she despises Hagrid for his half-giant status. She works hard to get him dismissed from Hogwarts once he gets back from his travels. He's on probation almost immediately, with testimony from jerks like Draco Malfoy making it sound as though Hagrid is stupid and violent. When Professor Umbridge finally succeeds in chasing Hagrid off Hogwarts premises, she removes one of Harry's greatest supporters at the school.
The thing is, Hagrid is exceptionally soft-hearted: he brings back his giant half-brother Grawp (the source of all of his horrible bruises) because he worries that Grawp is bring bullied by the other giants. And after Sirius's death, Hagrid tries to comfort Harry: "I knew Sirius longer 'n yeh did ... he died in battle, an' tha's the way he'd've wanted ter go —" (38.93). Hagrid's efforts to comfort Harry don't really work, but they do indicate once more what a good guy he is. Professor Umbridge's efforts to target Professor Trelawney (who is weak) and Hagrid (who is both lovable and extremely decent) really emphasize what a complete monster she is. Hagrid's generosity to all creatures provides a foil to Professor Umbridge's self-centered prejudices.