At the end of Spider-Man 3, Gwen Stacy is seated prominently among the first row of mourners at the funeral of Harry Osborn. Why? We've seen no sign up to this point that the two had ever met, and there's reason to think they never had. They didn't go to high school or college together, and they never dated. In his brief heroic stint at the end of the film, she was never in peril and he never saved her. She was, as far as we know, a stranger to him.
1 Answer
Because Gwen Stacy was in the same university as Peter and Harry:
A student in Peter Parker's university class in Spider-Man 2, portrayed by Ellen Pompeo, is identified as Gwen Stacy in the film's novelization. - wikipedia
Here is the novelization if you want to look.
In comics Gwen knows a lot of people from Peter's life and she had more prominent role, but in Sam Raimi's films, her role was cut short. And why Sam did that is discussed in this question.