He escaped when he realised Harry might be in danger.
As the comments point out, Sirius didn't really have a reason to escape before. All his friends were either dead or they believed him to be a killer and a traitor. What motivated him to escape Azkaban was the sudden realisation that Harry was in dangerously close contact with someone Sirius knew to be a murderer. The photo of Pettigrew on holiday with the Weasleys was the catalyst for action. Black's motivation was concern, not revenge.
“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...to where Harry was...”
(Prisoner of Azkaban, Chapter 19, The Servant of Lord Voldemort).
The knowledge that he was innocent helped Black maintain his sanity in Azkaban. That was more than anyone else in Azkaban had so it's possible that if he'd attempted an escape before seeing the photo that he may have managed it. However, the knowledge that Pettigrew posed a threat to Harry provided him not only with a motivation which he didn't have before but greater mental clarity as well.
“I think the only reason I never lost my mind is that I knew I was innocent. That wasn’t a happy thought, so the dementors couldn’t suck it out of me...but it kept me sane and knowing who I am...helped me keep my powers...But I was weak, very weak, and I had no hope of driving them away from me without a wand...
“But then I saw Peter in that picture...I realized he was at Hogwarts with Harry...perfectly positioned to act, if one hint reached his ears that the Dark Side was gathering strength again...ready to strike at the moment he could be sure of allies...and to deliver the last Potter to them. If he gave them Harry, who’d dare say he’d betrayed Lord Voldemort? He’d be welcomed back with honours..."
“So you see, I had to do something. I was the only one who knew Peter was still alive...”
Harry remembered what Mr. Weasley had told Mrs. Weasley. “The guards say he’s been talking in his sleep...always the same words...‘He’s at Hogwarts.’
“It was as if someone had lit a fire in my head, and the dementors couldn’t destroy it...It wasn’t a happy feeling ...it was an obsession...but it gave me strength, it cleared my mind.
(Prisoner of Azkaban, Chapter 19, The Servant of Lord Voldemort).
In conclusion, Black escaped only when he knew that Harry was in danger. That knowledge also gave him the mental focus he needed to get past the dementors.