To my knowledge, they didn't just pick random letters to substitute but
Peggy,
Peg,
Polly (
Molly),
Dick etc came about from usually younger siblings trying to say the nicknames. Linguistically P and D sounds are easier than M or R sounds for little kids, which is why so many children say
Papa or
Dada before Mama.
The nicknames would have stuck because of the lack of name variety though!