No pain had a different idea. Obito purposely got nagato killed because he wouldn't go along with the moon eyes plan. Juz my opinion. Obito couldn't bear pain I think and so he sent him on a suicide mission
but obito still needed nagato to revive madara..