Nagato was not born with the Rinnegan. It was implanted into him by the real Uchiha Madara before his (Madara's) death.
Uchiha Madara activated his Rinnegan at an old age, so he made a plan by which he could be revived using the Rinnegan's Rinne Tensei jutsu after Akatsuki captured all the Bijuu into the Gedo Mazo. He could then proceed with the Moon's Eye Plan.
He implanted his Rinnegan into Nagato, without Nagato realising it, and then made Uchiha Obito assume his identity as the fake Madara, so that Obito could both collect the Bijuus using the Akatsuki, and control Nagato to use the Rinne Tensei to revive Madara.
Source: Naruto Manga Chapter 606. I don't want to paste screenshots here, since the entire story is described fully in that single chapter.