Cedric Diggory was a clever wizard. He was very expert in the field of magic and he also proved it every time. These qualities are suggesting that he should be in Ravenclaw rather then Hufflepuff.
So why wasn’t he sorted in Ravenclaw?
The key point comes from Dumbledore’s speech about him in Goblet of Fire:
“Cedric was a person who exemplified many of the qualities that distinguish Hufflepuff house,” Dumbledore continued. “He was a good and loyal friend, a hard worker, he valued fair play.”
All of those are consistent with the portrayal of Cedric in the canon, hence, he was well suited in Hufflepuff.
We have characters in the canon who are highly intelligent and intellectually capable, yet aren’t in Ravenclaw. Hermione is the best example. As I explained in my answer to that question, the values you hold are more important than your individual traits.
Diggory has never shown the level of intellectual curiosity required to be in Ravenclaw, but as Dumbledore says above, he does value traditional Hufflepuff traits.
To somehow expand alexwlchan's answer I've tried to gather some information about Cedric's Hufflepuff qualities. I will focus on, why Cedric is in Hufflepuff, not why he is not in Ravenclaw. First let me cite the the Sorting Hat:
You might belong in Hufflepuff Where they are just and loyal,
Those patient Hufflepuffs are true
And unafraid of toil;
Harry Potter and the Philosopher's Stone
For Hufflepuff, hard workers were
Most worthy of admission;
Harry Potter and the Goblet of Fire
Now about Cedric (from the Prisoner of Azkaban):
Looks like he's not misusing his appearence or built, but remains humble/silent.
“He’s that tall, good-looking one, isn’t he?” said Angelina.
“Strong and silent,” said Katie, and they started to giggle again.
The before-match-handshake differs from those with Slytherin, when they try to crush each others hand:
The Captains walked up to each other and shook hands; Diggory smiled at Wood but Wood now looked as though he had lockjaw and merely nodded.
He is talented in Quidditch, a bit like Harry himself:
He’s an excellent Seeker!
He is fair-player, which tells a great deal about his personality:
“Diggory got the Snitch,” said George. “Just after you fell. He didn’t realize what had happened. When he looked back and saw you on the ground, he tried to call it off. Wanted a rematch. But they won fair and square... even Wood admits it.”
As a Quidditch player he knows how broom is important, and understands the Harry's loss:
Cedric Diggory came over to congratulate Harry on having acquired such a superb replacement for his Nimbus,
And from the Goblet of Fire:
The situation before Quidditch World Cup:
Ced, that’ll be something to tell your grandchildren, that will.... You beat Harry Potter!”
Harry couldn’t think of any reply to this, so he remained silent. Fred and George were both scowling again. Cedric looked slightly embarrassed.
“Harry fell off his broom, Dad,” he muttered. “I told you... it was an accident....”
“He’s not an idiot. You just don’t like him because he beat Gryffindor at Quidditch,” said Hermione. “I’ve heard he’s a really good student — and he’s a prefect.”
He is not angry with Harry entering the Triwizard Tournament, although he probably does not believe him:
“So,” said Cedric, with a slight smile. “We’re playing against each other again!”
“Ah... okay,” said Cedric. Harry could tell Cedric didn’t believe him. “Well... see you, then.”
He wasn’t attracting nearly as much unpleasantness in the corridors anymore, which he suspected had a lot to do with Cedric — he had an idea Cedric might have told the Hufflepuffs to leave Harry alone, in gratitude for Harry’s tip-off about the dragons. There seemed to be fewer Support Cedric Diggory! badges around too
“Listen . . .” Cedric lowered his voice as Ron disappeared. “I owe you one for telling me about the dragons.
“Tell you what,” Cedric said, “use the prefects’ bathroom. Fourth door to the left of that statue of Boris the Bewildered on the fifth floor. Password’s ‘pine fresh.’ Gotta go... want to say good night —”
The Triwizard Cup, final steps:
“You take it. You should win. That’s twice you’ve saved my neck in here.”
He stepped over the spider’s tangled legs to join Harry, who stared at him. Cedric was serious. He was walking away from the sort of glory Hufflepuff House hadn’t had in centuries.
“Go on,” Cedric said. He looked as though this was costing him every ounce of resolution he had, but his face was set, his arms were folded, he seemed decided.
And finally Dumbledore's speech:
“Cedric was a person who exemplified many of the qualities that distinguish Hufflepuff house,” Dumbledore continued. “He was a good and loyal friend, a hard worker, he valued fair play. His death has affected you all, whether you knew him well or not. I think that you have the right, therefore, to know exactly how it came about.”
Together I think he had a bit from everything. He was brave, clever, hard-working, talented, humble. He was not that much ambitious, he knew how to lose. That's why I think he fits in Hufflepuff.
Honestly, I don't see how Cedric didn't belong in Hufflepuff. He definitely had traits from each house, but he was a Hufflepuff through and through. He's probably one of the most humble characters in the entire series.
The first note of this is in PoA during the quidditch match between Hufflepuff and Gryffindor. When he finds out that Harry had fallen off his broom because of the dementors, he wants to have a rematch. He doesn't see it as a win, and when his father boasts about it later in GoF, Cedric is embarrassed and corrects him.
When Harry's name is pulled from the Goblet of Fire, Cedric doesn't believe Harry when he says he didn't put his name in, however, he remains very civil with Harry and later tells the Hufflepuffs not to wear the "Potter Stinks" badges and to, basically, lay off Harry.
Harry helped Cedric multiple times in GoF, and Cedric ALWAYS repaid him. Harry told Cedric about the dragons, Cedric told him about the egg and got the Hufflepuffs off his back. Harry saves his life TWICE in the maze and Cedric gives up the Triwizard Cup and the win. It's obvious to Harry that it's hard for him to give it up and Harry knows that Cedric has a lot riding on it. Cedric wants to win for himself, obviously, but he also wants to win for his dad and for Hufflepuff. Yet, he believes Harry deserves it more and is willing to give it up in his gratitude.
I don't remember if this came up in the book or not, but in the GoF movie, after the boys are transported to the graveyard and Harry's scar begins to burn, Cedric is genuinely concerned for Harry. Then, during Priori Incantatem, Cedric helps Lily and James (and others in the book) buy Harry time to get back to the portkey.
To me, all of this just SCREAMS Hufflepuff. He was loyal, true, kind, and fair. He was definitely "unafraid of toil", as the song goes. True he was smart and brave and ambitious, but his actions and his reasoning behind those actions totally fall in line with everything Helga Hufflepuff valued and wanted in her House.
You gotta be careful when talking about Hogwarts Houses not to assume that a Hufflepuff can't be brave, or a Slytherin can't be smart, or a Ravenclaw can't be cunning. Most people have a mix of traits. Students are not limited by their houses. Not at all.
I believe Cedric chose Hufflepuff, much like how Harry chose Gryffindor. What did Dumbledore say?
"Why, then, did the sorting hat place you in Gryffindor?"
"Because I asked it to."
"Exactly, Harry... It is not our abilities that show what we truly are. It is our choices."
Making his father proud was intensely important to Cedric. Perhaps Hufflepuff was a Diggory family tradition.
See how easy that was?