I know that Nagato used Yahiko's body to become 'Pain' but can anyone please tell me why and how he did it?
Nagato had an ability called the Outer Path using which he could revive the dead, transmit chakra to receivers. Using this ability of his, he created his Six Paths of Pain technique. He used the technique to embed some chakra rods into certain corpses (including Yahiko's) and transmitted his chakra to the rods to control the bodies.
As for why he did it, there are several reasons. Nagato got badly injured and damaged during his battle with Hanzo (the same one when Yahiko died). He was unable to move after that. Hanzo was still alive though. Nagato wanted to avenge Yahiko and he also wanted to continue their dream previous dream of peace (although his sense of peace got distorted). So Nagato still had to fight. That is why he created the Six Paths of Pain technique to allow himself to continue fighting and use his Rinnegan abilities. Secondly, he was very fond of Yahiko. He used Yahiko's body to form the strongest Deva Path. In terms of abilities, he was superior to the other paths.
As for what happened to Yahiko's body afterwards, well after Nagato died in the Hidden Leaf after the battle with Naruto, Konan retrieved the bodies of both Yahiko and Nagato and buried them in the Hidden Rain Village. And that is where Yahiko's body rests.