Why did Jiraiya have to die? In Naruto, when Jiraiya fights Pain, he goes out of the barrier to confirm his suspicion about Pain (that all the 7 pains are dead) but he could have used a shadow clone instead. Shadow clones can transfer knowledge and experience (as told by Kakashi) and if Jiraiya had the chakra to maintain the barrier, swim when he is badly injured and then be alive just to write a message on the back of the toad (apparently I forgot the toad's name), he could have had the chakra to create a shadow clone. Why didn't he do so? [Why did he have die? I feel so sad about him :'( ]
Jiraiya once said: "In the ninja world, it's not how you live. Rather, it's how you die." So I think he applied this quote in his final seconds.

First, we can assume that he hadn't had enough chakra to escape from Pein (don't forget, he was stabbed a lot of times with Pein's chakra absorbing rods), so his last efforts were to send a message to Konoha.

Second, I'm quite sure he knew that this would boost Naruto, so practically Jiraiya sacrificed himself to make Naruto (maybe) the strongest shinobi in the world.

Third, maybe he even knew that his body could be resurrected or used by Nagato as a host body, so he didn't even try to escape. Rather, he realized the seal of his body.

So Kishi had some reasons why to "kill" Jiraiya, but in my opinion, he had to go to make the later story happen.