Sirius Black is Harry's godfather. Sirius is also a convicted murderer of thirteen people and a confirmed Death Eater. Except, of course, as we discover in Book 3, Sirius has actually been framed by his one-time friend, Peter Pettigrew. Harry knows that Sirius is not a murderer, and Sirius has rejoined the Order of the Phoenix. However, the Ministry of Magic is still hunting for Sirius as the most dangerous Death Eater at large. This means that Sirius spends much of Book 5 in hiding. For an active man (who has already spent twelve years in Azkaban Prison under a false charge), being trapped inside a townhouse with nothing to do is absolute torture.
What makes Sirius's situation worse is the house he's stuck in: Number Twelve, Grimmauld Place. In addition to being a miserable, gloomy old pile that has been uninhabited for ten years, Number Twelve, Grimmauld Place is full of reminders of Sirius's horrible family. The Black family has been mostly bigoted wizards since its beginnings. In fact, the motto of the family is Toujours pur – "always pure" – demonstrating their commitment to the maintenance of pureblood wizard lines.
Sirius's cousin, Bellatrix Lestrange, is one of the cruelest of Voldemort's Death Eaters. Sirius's other cousin, Narcissa Black, is now Narcissa Malfoy – the mother of Harry's most hated school rival, Draco Malfoy. The Black family decided to disinherit one of Sirius's cousins, Andromeda Black, when she married a Muggle named Ted Tonks. Sirius ran away from his family when he was sixteen and moved in with his best friend, James Potter. Being back in his boyhood home brings back all kinds of grim memories Sirius doesn't need.
Sirius might have been able to stand the inactivity and the reminders of his childhood if it weren't for his old enemy, Professor Snape. Professor Snape is a member of the Order and a fairly frequent visitor to Number Twelve, Grimmauld Place. But he and Sirius cannot stand each other, and every time they see one another, they throw every hateful barb and nasty insult that they can think of. Professor Snape frequently goads Sirius about staying tucked away in Number Twelve out of the action like a coward. Perhaps without this constant taunting from Professor Snape, Sirius would have been able to resist rushing out into danger at the Department of Mysteries.
Sirius has another massive blind spot: Kreacher. Kreacher is his family's deranged old house-elf. After being trapped inside for ten years with only the portraits on the walls to keep Kreacher company, the elf has gone crazy. Sirius treats Kreacher as something without feelings, taunting him and kicking him aside as often as possible. There is some excuse for this behavior, since Kreacher reminds Sirius of a past he would rather forget. Kreacher loves the Black family and clearly thinks that Sirius is a horrible blood-traitor. At the same time, Dumbledore comments:
I warned Sirius when we adopted Twelve Grimmauld Place as our Headquarters that Kreacher must be treated with kindness and respect. I also told him that Kreacher could be dangerous to us. I do not think Sirius took me very seriously, or that he ever saw Kreacher as a being with feelings as acute as a human's — (37.111)
If Sirius had been capable of recognizing that Kreacher has been as damaged by the Black family as Sirius himself, perhaps Kreacher wouldn't have turned against Sirius so powerfully. But Sirius can't look at Kreacher as a living being, with real feelings. His self-centeredness regarding Kreacher has horrible consequences.
Despite Sirius's troubles with Professor Snape and Kreacher, we know that he is, at heart, a good man. J.K. Rowling comments, "Sirius's great redeeming quality is how much affection he is capable of feeling. He loved James like a brother and he went on to transfer that attachment to Harry" (source).
Sirius's deep love for Harry is evident throughout the book. Even though he knows that Voldemort is aware of his dog form, Sirius still accompanies Harry to the train station on his way to Hogwarts in his "Snuffles" shape. When Harry is desperate to talk about his troubles with Professor Umbridge, Sirius risks his life to Firecall the Gryffindor common room fireplace. And of course, when Sirius hears that Voldemort has lured Harry to the Department of Mysteries, Sirius comes running, personal safety be damned. Sirius loves wholeheartedly, which goes a long way to making up for his bitterness and his self-destructive recklessness.
It's absolutely miserable that Harry finally finds someone to love him unconditionally, someone who will risk anything (too much, really) to come and help him, only to lose Sirius so soon. When Sirius passes through the veil, Harry must confront the reality of losing someone close to him.
J.K. Rowling makes the case that Sirius's death is important for Harry's character development, as tragic as it is: "it is more satisfying I think for the reader if the hero [Harry] has to go on alone and to give him too much support [Sirius] makes his job too easy, sorry" (source). By removing Sirius from the series, Harry learns important lessons about personal loss and about avoiding recklessness. It's horrible to watch Sirius go, but we can also see how this is all part of J.K. Rowling's long-range plan to develop Harry's character for the final book.