It's possible that John is recalling Mark 3:28-30 (ESV)
“Truly, I say to you, all sins will be forgiven the children of man, and whatever blasphemies they utter, but whoever blasphemes against the Holy Spirit never has forgiveness, but is guilty of an eternal sin”—for they were saying, “He has an unclean spirit.”
The sense in Mark is a bit hard to understand, but the idea seems to be that if you see the Holy Spirit in operation and call it demonic, you are rejecting God altogether and won't be forgiven. (I also take it to mean that if such a person ever has a radical change of heart, they will accept the Spirit and be forgiven. But that's a separate question.)
Reading on in 1 John 5:17-21 (ESV):
All wrongdoing is sin, but there is sin that does not lead to death.
We know that everyone who has been born of God does not keep on sinning, but he who was born of God protects him, and the evil one does not touch him.
We know that we are from God, and the whole world lies in the power of the evil one.
And we know that the Son of God has come and has given us understanding, so that we may know him who is true; and we are in him who is true, in his Son Jesus Christ. He is the true God and eternal life. Little children, keep yourselves from idols.
It seems to me that John is drawing line between those who are in the family of God and those who are not. Those who are in the family will sin, but won't keep on sinning because of their relation to God. Extrapolating a bit, those who are in God will be protected from death but for those outside, sin leads to death. Our prayers aid in the process of protecting believers from death.
There's plenty of confirmation of the idea in the earlier part of the letter, such as 1 John 2:1 (ESV):
My little children, I am writing these things to you so that you may not sin. But if anyone does sin, we have an advocate with the Father, Jesus Christ the righteous.
If you don't go to the advocate, you can't get the pardon of sin. Also 1 John 1:9-10 (ESV):
If we confess our sins, he is faithful and just to forgive us our sins and to cleanse us from all unrighteousness. If we say we have not sinned, we make him a liar, and his word is not in us.
Does this mean that we shouldn't pray for nonbelievers or against their sin? Well, the letter talks about a special class of unbelievers he labels as "antichrist". 1 John 2:22 (ESV)
Who is the liar but he who denies that Jesus is the Christ? This is the antichrist, he who denies the Father and the Son.
It seems that some people in the community John is writing to pretended to believe, but were spreading lies. The whole letter serves as a warning against these people. (2nd John, which might be a cover letter for 1st John, suggests not even greeting these people.) It seems that John has written them off altogether and doesn't want them to be a distraction even in prayer.
See also, a rather extensive, exegetical commentary by W. Hall Harris III.