He got hit by a double meat tank and tanked tailed beast ball easily. And he's able to block sage mode taijutsu. But how did he get killed by a stupid rasengan?
When Naruto was in his tailed beast form, Pain was retreating in order to perform the Chibaku Tensei Justu.
To perform this technique through one of his Six Paths of Pain, Nagato needed to bring his Deva Path in close proximity to his body so that he could channel his chakra to it more effectively
While Deva Path was retreating, Nagato focused his strength and charka into Deva Path in order to survive the barrage of attacks received by Naruto.
In the aftermath, the draw back to the Chibaku Tensei Justu was that it caused severe stress to Nagato
At low chakra levels, it placed a massive strain on his body which caused him to bleed from the mouth and nose
Because of the massive stress Nagato took, while Deva Path could still use his attractive and repulsive abilities, Nagato was not able exert enough charka in order for Deva Path to survive