He wanted protection and thought the Dark Lord was winning.
Sirius basically says that Pettigrew wanted to be allied with whoever he thought was most powerful, which seems like how he consistently behaved.
“When did I ever sneak around people who were stronger and more powerful than myself? But you, Peter – I’ll never understand why I didn’t see you were the spy from the start. You always liked big friends who’d look after you, didn’t you? It used to be us … me and Remus … and James …”
- Harry Potter and the Prisoner of Azkaban, Chapter 19 (The Servant of Lord Voldemort)
Pettigrew gravitated to whoever he thought was the most powerful and able to protect him. As a Gryffindor at Hogwarts, the Marauders were likely the best group for him to go to for protection - they were in his house and seemed to be highly regarded among the student body. There was a group of young Death Eaters in the making, but they didn’t seem to offer much protection or status - Snape was one and he was bullied mercilessly by the Marauders. Joining them wouldn’t help Pettigrew much, especially as a Gryffindor who’d have to share a common room and dormitory with the Marauders where he’d be “unprotected” from them. In addition, the Marauders were probably the best at bullying during his time at Hogwarts. Being one of the Marauders would mean he wasn’t on the receiving end of any of their bullying.
Pettigrew had at first joined the Order of the Phoenix - he was in the picture of the original Order members. He hadn’t gone straight to the Dark Lord after the Marauders. He’d originally followed in the footsteps of the other Marauders, joining the same group as them.
“Harry’s heart turned over. His mother and father were beaming up at him, sitting on either side of a small, watery-eyed man whom Harry recognised at once as Wormtail, the one who had betrayed his parents’ whereabouts to Voldemort and so helped to bring about their deaths.”
- Harry Potter and the Order of the Phoenix, Chapter 9 (The Woes of Mrs Weasley)
However, Pettigrew wanted protection and safety most of all, and being a member of the Order was very dangerous. Many of the people in that picture died fighting the Dark Lord - among the 22 members, there were six confirmed deaths and one who vanished (not even counting the Longbottoms or the Potters, who died after Pettigrew defected -counting them would make 10 confirmed deaths).
“That’s Edgar Bones … brother of Amelia Bones, they got him and his family, too, he was a great wizard … Sturgis Podmore, blimey, he looks young … Caradoc Dearborn, vanished six months after this, we never found his body … Hagrid, of course, looks exactly the same as ever … Elphias Doge, you’ve met him, I’d forgotten he used to wear that stupid hat … Gideon Prewett, it took five Death Eaters to kill him and his brother Fabian, they fought like heroes … budge along, budge along …”
- Harry Potter and the Order of the Phoenix, Chapter 9 (The Woes of Mrs Weasley)
When Pettigrew decided to join the Dark Lord, it seemed like the Dark Lord’s rise and takeover of the wizarding world was inevitable. He basically says so himself (though he’s begging for his life at the time). It seems pretty clear that the majority of the wizarding world thought that the Dark Lord’s rise was inevitable.
“DON’T LIE!’ bellowed Black. ‘YOU’D BEEN PASSING INFORMATION TO HIM FOR A YEAR BEFORE LILY AND JAMES DIED! YOU WERE HIS SPY!’
‘He – he was taking over everywhere!’ gasped Pettigrew. ‘Wh-what was there to be gained by refusing him?”
- Harry Potter and the Prisoner of Azkaban, Chapter 19 (The Servant of Lord Voldemort)
No one expected his fall at the Potters’ house - when Pettigrew joined him he was at the height of power. After that fall, Pettigrew made no move to find or rejoin him until being forced out of hiding as a rat when he was revealed to be alive and a traitor. He wasn’t loyal to the Dark Lord, the Marauders, or anybody in particular - he went with whoever he thought could best protect him.
In addition, when the Dark Lord was at the height of his power, he was a very deadly enemy - those who opposed him were killed. Pettigrew, as a Gryffindor and known friend of the Potters, would have found himself in danger simply because of that. Becoming a spy and giving information about the Potters made the Dark Lord see him as an ally and lessened the danger he was in.
J.K. Rowling also mentioned this, though somewhat obliquely, when addressing why Snape wanted to join the Death Eaters.
Nithya: Lily detested mulciber,averyif snape really loved her,why didnt he sacrifice their company for her sake
J.K. Rowling: Well, that is Snape's tragedy. Given his time over again he would not have become a Death Eater, but like many insecure, vulnerable people (like Wormtail) he craved membership of something big and powerful, something impressive.
Bloomsbury Live Chat, (July 30, 2007)