Before Tom Riddle became Voldemort, he was far more secretive about his wrongdoings. He was already committing some of the worst crimes imaginable even while still at Hogwarts, but he did it all behind-the-scenes, while outwardly appearing to be trustworthy and responsible. Dumbledore was the only professor who could see through all that, and even he didn’t realize what Tom Riddle would eventually become.
So, whenever Tom Riddle did something truly horrible, like murder, he never took the blame for it himself. He always made it seem as if some innocent bystander was responsible. Hokey the House Elf accidentally poisoned Hepzibah Smith’s tea. Morfin Gaunt murdered Tom Riddle Sr. and his parents. Hagrid opened the Chamber of Secrets.
The people he framed were always vulnerable to suspicion. House Elves are not seen as wizards’ equals, so it must have been easy to accept Hokey’s bewitched confession as truth and move on. The Gaunts were a family of muggle-hating dark wizards, so naturally they would be the first suspects when a nearby family of muggles was murdered. And Hagrid? While he would never intend for one of his monsters to hurt anyone, he does have an odd fascination with them. Even Harry is willing to believe he opened the Chamber of Secrets as a child, just to get a look at whatever was in there and give it a chance to stretch its legs.
What we see for the first time in Chamber of Secrets is a pattern that repeats itself again and again as we learn more about Voldemort’s backstory. It’s also a pattern that repeats itself in other characters’ stories. Stan Shunpike was arrested in Half-Blood Prince, even though nobody really believed he was working for Voldemort. Sirius Black spent twelve years in Azkaban without a trial for a crime committed by Peter Pettigrew, one of his supposed victims. It’s implied he may not be the only innocent person in that situation, since many others were sentenced without trials. And Barty Crouch, Jr., turns out to definitely be guilty, but when he’s first introduced in the penseive flashbacks, as a twenty-something boy sobbing and insisting he’s innocent, we’re expected to believe he might be. That only works because there’s an established pattern of innocent people being blamed for – or framed for – horrible crimes.
Hagrid is the first obvious example of this, but even Snape and Quirrel are similar. One is obviously guilty and the other clearly harmless, up until the end, when it’s revealed that the harmless one is responsible for everything that’s been happening at Hogwarts. The point, I think, is that it’s not always easy to tell at first glance what someone is really like, and that makes it easy for someone like Tom Riddle to literally get away with murder.