Pein had a sad childhood due to the Second Great Shinobi War. He lived with his parents, who were from the Uzumaki clan, in a village near Amegakure. One day, 2 Konoha shinobi broke into their home looking for some food. Believing they were going to be killed by them, Nagato's parents attacked the two shinobi to allow Nagato to get away. Having mistaken them to be enemies, the Konoha ninja killed his parents. As soon as Nagato saw this, he ended up awaking his Rinnegan and killed the assailants. Nagato came to consider this incident as the great pain of his existence.
Due to him having no family, friends nor allies, he ended up wandering the country, going from house to house asking for food and water. In time, he ended up meeting a dog, which he named Chibi. Soon after, he also met Konan and Yahiko. With this trio formed, they traveled together in search of food. But as time went on, they ended up in a cross fire which resulted in Chibi being killed, which was between Hanzou and the soon-to-be three Konoha Sannin. With this, Nagato promised himself that he would change the world.
Later on, the trio ended up looking for the Sannin, since they wished to be trained in the way of the shinobi. They ended up finding one of the Sannin, Jiraiya, who stayed with them for several years teaching them the ways. Whilst Jiraiya taught them, Yahiko and Nagato were attacked by an Iwagakure (Hidden Rock Village) ninja. This activated Nagato's Rinnegan yet again and saved Yahiko. When Jiraiya found out about this, he decided to teach them ninjutsu. As it turned out, Nagato was emotional about killing ninja, so he asked Jiraiya for help so he could protect the people dearest to him. Jiraiya's response to this was to grow up and use his eyes to find peace that they both desired for the world.
Over the years after Jiraiya left, Nagato became a full fledged ninja of Amegakure and gathered up followers who shared the same dream as him. But it seems that Hanzou, the leader of Amegakure, found them a threat and ended up making plans with Konoha's Root to eliminate them. Hanzou ended up luring Nagato and Yahiko into an ambush, where Nagato had to choose between the killing of either Konan or Yahiko. Nagato did not want to make a choice, and Yahiko himself chose to impale himself with a kunai which was placed into Nagato's hand.
With this little event, Nagato ended up using the summoning jutsu Demonic Statue of the Outer Path. This killed all Hanzou's men but the technique left Nagato emaciated with numerous chakra rods embedded all over his back. Later on, Nagato changed his name to Pein, killed Hanzou and took over Amegakure. With this, the Six Paths of Pein were born.
They included the following Paths: Deva Path, Asura Path, Human Path, Animal Path, Preta Path and Naraka Path. The seventh was the Outer Path, which controls life and death. Each of the Six Paths of Pein bodies were reanimated corpses of shinobi who were in some way affiliated with Jiraiya when they were still alive. Nagato used his own chakra to control all of the Paths through chakra rods.
Pein is also the one who killed his former sensei, Jiraiya. Jiraiya entered the Hidden Rain Village through a frog, hoping to find some valuable information regarding the Akatsuki leader. He was then found by Konan and later by Pein. Jiraiya put up a good fight even against all of the Paths, but in the end, he sacrificed himself to see if he had finally come to understand the Six Paths of Pein technique. Just before receiving the final blow, he called out a toad and wrote a coded message for Konoha, regarding the truth behind the aforementioned technique, hoping that Naruto and the others will understand it. Jiraiya died with a smile on his face.
When only the Nine and Eight-tails were left to be captured by the Akatsuki, Pein and Konan set out to Konoha. They caused the entire Leaf Village to be destroyed and a fierce battle between Pein and Naruto began. But at the end of the battle, Naruto ended up destroying all of the Paths and meeting up with the real Pein, Nagato himself. Both of them spoke. Upon this discussion, it became clear to Nagato what he had done and what he had caused. Nagato regretted everything and asked Naruto to do what he could not - bring peace to the shinobi world. In the end, Nagato sacrificed himself to revive everyone he had killed within the village.