Rowling maintained throughout the entire series this notion of how incompetent the Ministry of Magic is. They are a bunch of paper-pushing bureaucrats who mindlessly follow rules and ordinances, and they have a tendency to insulation and confirmation bias, in particular Cornelius Fudge's refusal to acknowledge the return of Voldemort.
But I don't think Rowling ever realized just how incompetent the Ministry really is.
In Harry Potter and the Chamber of Secrets, an old diary unleashes the spirit of Voldemort from the past. Taking over the body of Ginny Weasley, this phantom unleashes upon the school an ancient beast of legend that stalks the school grounds at night, turning hapless bystanders to stone. In the chaos and confusion caused by this, we learn the events that led to Hagrid's expulsion from Hogwarts and the revocation of his wand.
Way back when, Hagrid was for whatever reason a Slytherin in Hogwarts, and his roommate just happened to be Tom Riddle, who would become Voldemort. I don't know how House Slytherin makes any sense in terms of Hagrid's character, or why Hagrid would be such a die-hard Gryffindor fan, but whatever. Hagrid used to be Voldemort's roommate. [edit: I swear, I read this in the book, but I can't find it on the internet; Rowling is now claiming Harid is a Gryffindor, which just makes what follows even worse. 2nd edit: I may have fallen asleep after reading this part and dreamed the rest, then forgotten it was a dream. That happens to me a lot.]
Even back then, Hagrid had an affection for dangerous magical animals, in particular his giant spider, Aragog, that he kept in a box in his room.
During Hagrid's stay at Hogwarts, someone (I'm sure you know who...) unleashed the monster from the Chamber of Secrets, and it went about at night terrorizing the campus. Solid citizen and all-around good-guy Tom Riddle tipped off the authorities that actually it was Hagrid who was doing this, Hagrid the half-giant who is quite obviously the heir of famous wizard pure-blood idealist Salazar Slytherin, who has opened the Chamber of Secrets and is keeping the dangerous legendary Basilisk in a shoebox in his room, except it isn't a Basilisk and is actually a spider with no known ability to cause petrification, and Hagrid who is unleashing it on the muggle-born students he pretty obviously hates.
And so when they found the spider, they knew that it just had to be true.
So, right up front, the Ministry is pretty dumb for believing this for even moments. Aragog is a spider; the monster in the Chamber was known to be a Basilisk. The monster in the Chamber was petrifying students; acromantula venom does not have that effect. Hagrid is a half-giant; Slytherin hated half-breeds.
But maybe Rowling was making a point about unfair accusations from authorities? So I'll let that slide, as it isn't even the worst part.
At the testimony of Tom Riddle and pretty much no one else, and against the testimony of Dumbledore and pretty much everyone else, the Ministry of Magic is now convinced, convinced, that Hagrid has opened the Chamber. Hagrid has killed those students. The Ministry is convinced that Hagrid has been using dangerous magical beasts to kill students on the Hogwarts campus. They believe this fully. As punishment, they expel him from Hogwarts (I guess the Ministry can do that?). They break Hagrid's wand. They forbid him to practice magic ever again. This prohibition against magic is in place for the majority of Hagrid's life.
As consolation, they instead hire him on to be the Keeper of Keys and Grounds.
Here is the job description, according to the Harry Potter wiki:
The Hogwarts gamekeeper had many duties, including:Did you catch that? Fifth bullet point down. Looking after magical beasts on the school grounds? The guy just convicted for using magical beasts on the school grounds to KILL STUDENTS? And what sorts of beasts are these on the school grounds? For starters, the very same spider you believe he was using to kill the students. Now not only is he enabled to spend time with dangerous magical beasts in the creepy forest of doom in the very scene of the crime, he is in fact now being paid to do this.
- Looking after the school's keys.
- Escorting first year students on the boats to the castle.
- Tending to the gardens at Hogwarts.
- Performing special tasks for the Headmaster and Professors at the school.
- Looking after magical beasts on the school grounds.
- Tending to matters in the Forbidden Forest.
- Bringing the twelve Christmas trees into the Great Hall during December.
- Defrosting the school brooms during winter.
- Making the pumpkins for the Hallowe'en feast.
They really handed the fox the keys to the henhouse there, didn't they?
Like, seriously, imagine if a football player expelled from high school for beating up kids in the locker is then hired at that same school as the staff member in charge of monitoring the locker room. That's not as obscene as this hiring decision.
And then it gets worse, because the Ministry keeps on believin' that Hagrid is the murderer in question and keeps on forbidding him the use of magic. At the time of the first book, the prohibition still stands. They still believe him guilty a full ten years after the death of his accuser Voldemort, the infamous Parsel-tongue pure-blood wizard idealist, literally descended from Salazar Slytherin, most well-known for capturing and murdering muggle-born wizards during the First Wizarding War -- less well-known for also being mild-mannered do-gooder Tom Riddle.
The Ministry has known for decades that Tom Riddle, the single witness and accuser of Hagrid, is a pure-blood idealist, that he is a murderer, that he is a Parsel-tongue. They have known that he wishes to expel all muggle-borns from Hogwarts. They have known that, hey, he was also at Hogwarts at the time the Chamber of Secrets was opened. And he was so forthcoming with information back then, then suddenly went all rebel and starting killing mudbloods like that unscrupulous Hagrid.
The Ministry continues to hold its ruling on Hagrid; definitely guilty, definitely can't do magic.
Almost worse, is that even after the reveal on Tom Riddle, Dumbledore -- Albus Dumbledore, the greatest wizard alive, the brilliant brain behind all the workings of the series -- Dumbledore never thinks to appeal the decision. Never calls it to the Ministry's attention that, hey, no one accused Hagrid but Voldemort and maybe he's not such a reliable witness. Dumbledore just lets his half-giant friend go on, magicless.
And I know what you're thinking; maybe Dumbledore did try to appeal it, but the Ministry was so set in their ways that they wouldn't listen.
Except that the Ministry does listen. By the end of the second book, they do revoke their sentence. They don't revoke it because anyone points out that charges made by Voldemort are pretty obviously bogus, that Hagrid has never been linked with pure-blood ideology, nor has he been linked with a basilisk, nor linked to anything related to Salazar Slytherin's mad scheme of revenge. They don't revoke it because they realize that Tom Riddle was almost definitely the real culprit, based on his known motives and means and actions and ancestry. None of that persuades them; in the face of it, they remain convinced. Hagrid did it.
What does persuade them is the testimony of three school children -- the one unleashing the monster, her brother, and her boyfriend -- that a little-understood and little-known magical artifact that contained the essence of Voldemort's soul possessed the little girl and caused her to open the Chamber, and then, in front of precisely the culprit, her boyfriend, her brother, and absolutely no one else, the Spirit of Voldemort began reciting its grand plan of revenge, confessing to all of the recent crimes as well as all of the past crimes committed by the children's favorite teacher, exonerating all of them from the charges. And then the spirit disappeared and will never show up again, but here's this empty book with a tooth in it as proof. Also, we concussed this teacher.
Upon hearing this unshakable testimony, the Ministry of Magic is compelled to revoke their previous sentence of Hagrid. They are forced to acknowledge Tom Riddle, alias Voldemort, as being the true culprit of the 1942 crimes. Hagrid is re-instituted as a wizard, his wand is repaired, and he is allowed to practice magic and teach wizard lessons, and probably given many heart-felt apologies from the Ministry.
Let's recap the actions and thought-processes of the Ministry of Magic, the agency responsible for the governance of the entire Wizarding community of England, as revealed in Chamber of Secrets. They bought trumped-up charges that a half-giant in [apparently] the Gryffindor House with no history of violence or prejudice at all was in fact the Heir of Slytherin and had opened the Chamber of Secrets, and was using the monster found therein -- a juvenile acromantula that had somehow not aged in hundreds of years locked in a cavern -- to petrify muggle-born students at Hogwarts, despite acromantulas having no reported ability of petrification. Fully buying these charges, they forbade Hagrid the use of magic -- magic, and not magical beasts, which he can still own and train -- and used their political power to have him expelled from Hogwarts School of Wizardry and Witchcraft. But then they -- and all the wizarding community, really -- turned a blind-eye when this half-giant convicted of murdering students with magical beasts is then hired back on at Hogwarts, the scene of his crimes, to be explicitly in charge of magical animals. Whatever... not worth their notice. But despite not caring that Hagrid is employed in the vicinity of the children he was murdering with increased access to murderous monsters, they still definitely believe Hagrid is guilty. They continue to enforce their sentence on him, right up to the events of the story. They continue to enforce it even when it is later revealed the only witness -- that is, Voldemort -- is in fact an evil and maniacal genocidist who tortures his own friends for fun. They continue to enforce their sentence when it is later revealed that the only witness is also the single best possible culprit to the crimes, as Voldemort was there, was involved in the crime investigation, was a pure-blood idealist, was capable of murder, was a Parselmouth, and was descended from Salazar Slytherin. The (probable) pleas of Dumbledore for an appeal and re-evaluation based on the tainted character of the witness doesn't phase them one bit. But, some decades later, this same Ministry of Magic is swayed by the completely unverifiable and incredible account of three children -- well known for trouble-making -- who stand to be held accountable for the recent spree of Chamber-of-Secrets-related crimes, an account that conveniently excuses them from all activity in the Chamber and for their apparent assault on a documented hero and professor at the school, and likewise an account that exonerates the charges against Hagrid, their close friend, and places all the blame on the typical bogey-man of legend who has been dead or missing for ten years, without any evidence (besides a dead basilisk and empty book) in support of it. This is the kind of testimony that the Ministry of Magic finds credible. So much so, that they overturn their standing conviction of some fifty years, a conviction that they have upheld even in the face of the (surely) fervent protests of the most famous and revered hero of the Wizarding Wars, Albus Dumbledore. His arguments weren't any good, but this -- this new and impossible story from some kids -- this changes everything.
Who are these people, anyway?