Everyone's been mocking Ned for making stupid choices, and I don't really mind because it's funny. But the truth in the text is that he's an intelligent man caught in a series of heartless betrayals, and he's doing the best he can. In the North, he's not only an honorable leader, he's an ideal leader, and the North is no small potatoes. For the last fifteen years, Ned's been taking care of half the kingdom and doing a damn good job of it. He just happens to have a terrible king as a best friend.
I'm quoting this passage from the book for the benefit of anyone who watched but hasn't read. The show made it almost impossible to sympathize with Robert, and by extension, hard to see why Ned trusted him and cared for him. I won't speak up in defense of Robert, because there's no defending an abusive alcoholic train wreck like him, but this made me think:
"I am sorry for your girl, Ned. Truly. About the wolf, I mean. My son was lying, I'd stake my soul on it. My son...you love your children, don't you?"
"With all my heart," Ned said.
"Let me tell you a secret, Ned. More than once, I have dreamed of giving up the crown. Take ship for the Free Cities with my horse and my hammer, spend my time warring and whoring, that's what I was made for. The sellsword king, how the singers would love me. You know what stops me? The thought of Joffrey on the throne, with Cersei standing beside him whispering in his ear. My son. How could I have made a son like that, Ned?"
"He's only a boy," Ned said awkwardly. He had small liking for Prince Joffrey, but he could hear the pain in Robert's voice. "Have you forgotten how wild you were at his age?"
"It would not trouble me if the boy was wild, Ned. You don't know him as I do."
And on the next page:
This was the boy he had grown up with, he thought; this was the Robert Baratheon he'd known and loved. If he could prove that the Lannisters were behind the attack on Bran, prove that they had murdered Jon Arryn, this man would listen. Then Cersei would fall, and the Kingslayer with her, and if Lord Tywin dared to rouse the west, Robert would smash him as he had smashed Rhaegar Targaryen on the Trident. He could see it all so clearly.
Robert's an ass, but like so many other characters, he's also a tragedy. He doesn't want to do any harm, and he does care about the kingdom enough to be afraid to leave it to Joffrey. He's also more than capable of loving his children; in another chapter, Ned remembers Robert's first bastard and how he doted on her. Joffrey's twisted development might have had something to do with his (alleged) father's incompetence, but it's also clear that Robert wanted to step in and raise the boy right. And thanks to Cersei, he could not do it. She cut him off emotionally from his (alleged) son, and all but ensured that the next generation of the monarchy was going to Lannister pot.
Cersei, of course, was a woman caught in a loveless marriage, and nothing she did could make her deserve the way he treated her. Ned didn't even want her or Joff to die for who they were or what they'd done, and I think he was right in that, too. But she's bad to the core. She's selfish, she's cruel, and she raised her children with the intent of using them for her own political agenda. Robert was a guy who just couldn't comprehend that kind of evil, let alone deal with it. He wasn't corrupted. He decayed.
So maybe I'm as dumb as Ned is supposed to be for this, but I believe he could have saved his friend. Take Cersei and Jaime and Littlefinger out of the equation, and the Hand of the King could have rebuilt the kingdom.
Until Dany swept in and burned them all to crisps, anyway.