In the 19th century, when the name Margret first became popular, a group of scientists did a conductive study to determine if there were any similar traits between people with the same name. The study found that women with the name Margret were more likely to be obese than women with a different name. One Margret in particular was known as the fattest woman in the entire city of London. She became known as "Margret the Piggy". However, even then, people had the courtesy to not call her that to her face. Instead, they simply called her Peggy. And thus, the name spread throughout the earth and is still used for Margrets everywhere today.
In medieval times, it was common to make pet forms of names by replacing the first letter of other pet forms. That's where we get Bob from Robert (Rob) and Dick from Richard (Rick). Meg is a pet form of Margaret. The M was replaced by a P, and the 'ie' sound added at the end. That's why Peggy's short for Margaret.