In Harry Potter: The Prisoner of Azkaban, why did Sirius Black come to the Gryffindor rooms? What was his purpose ?
He was looking for Peter Pettigrew.
Sirius's whole purpose in breaking out of Azkaban and coming to Hogwarts was to kill the traitor who'd caused the deaths of his friends and his own false imprisonment. That's why he kept muttering "He's at Hogwarts" even while still in Azkaban (leading people to think he was hunting for Harry to kill him).
His breakin to the Gryffindor common room was the closest Sirius ever got to actually catching and killing Pettigrew/Wormtail/Scabbers until near the very end when he really did catch him. That's why he was standing over Ron's bed holding a knife. Not Harry's bed, Ron's - because it was Ron's pet he was looking for. From the book:
Ron was sitting up in bed, the hangings torn from one side, a look of utmost terror on his face.
“Black! Sirius Black! With a knife!”
“Here! Just now! Slashed the curtains! Woke me up!”
-- HP and the Prisoner of Azkaban, Chapter 13: Gryffindor vs Ravenclaw
And later on, Sirius himself relates how he broke into Gryffindor Tower, with help from Crookshanks, in order to find Pettigrew, but failed:
“[Crookshanks] tried to bring Peter to me, but couldn't... so he stole the passwords into Gryffindor Tower for me... As I understand it, he took them from a boy's bedside table...”
Harry's brain seemed to be sagging under the weight of what he was hearing. It was absurd... and yet...
“But Peter got wind of what was going on and ran for it.” croaked Black. “This cat—Crookshanks, did you call him?—told me Peter had left blood on the sheets... I supposed he bit himself... Well, faking his own death had worked once.”
-- HP and the Prisoner of Azkaban, Chapter 19: The Servant of Lord Voldemort
Sirius Black came to the Gryffindor Tower to kill Peter Pettigrew.
Sirius had figured out that Ron Weasley's pet rat Scabbers was actually Peter Pettigrew hiding as his Animagus form.
"You know, Sirius, that's a fair question," said Lupin, turning to Black and frowning slightly. "How did you find out where he was?"
Black put one of his clawlike hands inside his robes and took out a crumpled piece of paper, which he smoothed flat and held out to show the others. It was the photograph of Ron and his family that had appeared in the Daily Prophet the previous summer, and there, on Ron's shoulder, was Scabbers.
"How did you get this?" Lupin asked Black, thunderstruck.
"Fudge," said Black. "When he came to inspect Azkaban last year, he gave me his paper. And there was Peter, on the front page on this boy's shoulder... I knew him at once... how many times had I seen him transform? And the caption said the boy would be going back to Hogwarts..."
Harry Potter and the Prisoner of Azkaban Chapter 19: The Servant of Lord Voldemort
Peter Pettigrew betrayed the Potters to Voldemort and framed Sirius for it. Sirius cornered Pettigrew on a Muggle street after the incident and Pettigrew blew up the street, transformed into a rat, and escaped, killing many Muggles. Sirius was assumed guilty for betraying the Potters, killing Pettigrew and all the Muggles and sent to Azkaban. Sirius escaped when he realized Pettigrew was alive and came to Hogwarts to avenge the betrayal of the Potters.