"Go on, have a pasty," said Harry, who had never had anything to share before or, indeed, anyone to share it with. It was a nice feeling, sitting there with Ron, eating their way through all Harry's pasties, cakes, and candies (the sandwiches lay forgotten). (6.171)
This tells us right away that Harry is, deep down, a good and generous person. Living with the Dursleys hasn't drummed all the morals and values out of him. At the first opportunity to participate in sharing, that's exactly what he does. He's rewarded with the "nice feeling" of a shared meal and also with a good friend for life.
He turned back to Harry. "You'll soon find out some wizarding families are much better than others, Potter. You don't want to go making friends with the wrong sort. I can help you there." (6.244)
Funny how certain individuals are convinced about who is the right and "wrong sort," and stick to their ideas with passionate conviction. Here, Malfoy shows his prejudice by discriminating between pure and mixed-blood "wizarding families." He implies that you should make friends with people just because of their family background. What's ironic about this is that, just as Malfoy judges others for being the "wrong sort," people like the Dursleys would judge him as the "wrong sort," based on the idea that he can do magic at all.
"Look!" said Malfoy, darting forward and snatching something out of the grass. "It's that stupid thing Longbottom's gran sent him."
The Remembrall glittered in the sun as he held it up.
"Give that here, Malfoy," said Harry quietly. Everyone stopped talking to watch. (9.40-42)
The term's just barely started, and the first-years are taking sides and forming alliances already. Harry's not going to let Malfoy get away with taunting a fellow Gryffindor (Neville), while Malfoy's capitalizing on the beginnings of Harry's friendship with Neville to really just get to Harry.
"That Quidditch cup'll have our name on it this year," said Wood happily as they trudged back up to the castle. "I wouldn't be surprised if you turn out better than Charlie Weasley, and he could have played for England if he hadn't gone off chasing dragons." (10.65)
For Harry, the exciting thing about Hogwarts isn't just getting to be friends with other open-minded first years – it's the chance to be part of and embraced by a whole community. Here's this older, well-regarded student encouraging and praising Harry, and taking time to welcome him to the team. It's a far cry from the Dursleys' household.
Someone knocked into Harry as they hurried past him. It was Hermione. Harry caught a glimpse of her face – and was startled to see that she was in tears.
"I think she heard you."
"So?" said Ron, but he looked a bit uncomfortable. "She must've noticed she's got no friends." (10.78-80)
Poor Hermione. Ron should "look[s] a bit uncomfortable" here, as he's totally gone too far in insulting her, but then he makes matters worse by accusing her of having "no friends." Hermione's "tears" show how much having friends matters at Hogwarts and how deeply Ron has hurt her feelings. For once, Harry's not the one worst off in the room; having no friends at Hogwarts is almost as bad as not having any in Little Whinging.
But from that moment on, Hermione Granger became their friend. There are some things you can't share without ending up liking each other, and knocking out a twelve-foot mountain troll is one of them. (10.160)
We might say, finally – this took them long enough. If you've read the rest of the books, you know that the friendship between Harry, Ron, and Hermione is one of the series' defining characteristics. The three really depend on each other to succeed.
It was really lucky that Harry now had Hermione as a friend. He didn't know how he'd have gotten through all his homework without her, what with all the last-minute Quidditch practice Wood was making them do. (11.4)
If Harry thinks he's "really lucky" to have Hermione around now, just wait until they're fighting for their lives in the forbidden third-floor corridor. This is welcome praise from Harry, but he doesn't realize how lucky he is to have Hermione reminding him of the importance of focusing on the academic side of Hogwarts. (This goes for Ron too.)
Ron and Hermione joined Neville, Seamus, and Dean the West Ham fan up in the top row. As a surprise for Harry, they had painted a large banner on one of the sheets Scabbers had ruined. It said Potter for President… (11.41)
While the book focuses mainly on Harry's relationships with Ron and Hermione – and to some extent Neville – it's nice to see that he has a much larger friend group, and that so many of the Gryffindor first years support and encourage him. This scene shows how Harry has become part of a real community and can count on his friends to root for him.
"But will it cover all three of us?" said Ron.
"All – all three of us?"
"Oh, come off it, you don't think we'd let you go alone?"
"Of course not," said Hermione briskly. "How do you think you'd get to the Stone without us?" (16.92-95)
This kind of thing is how you tell who your friends really are. Luckily for Harry, his friends are just as brave (and foolish, maybe) as he is. There's no question here of either Ron or Hermione letting Harry go by himself. Despite their best intentions, though, they can't accompany him all the way.
"I'm not as good as you," said Harry, very embarrassed, as she let go of him.
"Me!" said Hermione. "Books! And cleverness! There are more important things – friendship and bravery and – oh Harry – be careful!" (16.288-89)
Of all the important qualities mentioned in this passage, friendship tops the list. Friendship matters more than just learning, or just being brave – those things matter too, of course, but friendship is at the core of it all. Harry values Hermione's academic success, which is nothing to sneeze at, but she reminds him that in the life-and-death situations that they're facing, friendship is one of the only things that will help them through.