1 John 5:14 And this is the confidence we have in his presence - that whenever we request something according to his will, he hears us; 15 and if we know that he hears us, what it is whenever we ask it, we know that we have those requests which we have asked from him.
I've been back in 1 John this past 6 weeks, as our church works its way through the letter, and I find this verse to be a kind of terrifying comfort. It's the second time in the letter that John speaks about our confidence in prayer, that we have what we ask for, and it echoes similar statements from the gospel, esp John 16 and that the Father will give us whatever we ask "in [Jesus'] name".
The certain knowledge that he hears ask, in verse 14, leads to a second confidence: that God hears and answers. In fact, that we already have the thing we have asked for. And yet, we clearly don't get everything we ask God for. And that's where I think the terrifying confidence comes from, because the rider is always 'according to his will'.
In 16-17 John goes on to speak about something that believers should pray for, and pray for with confidence. That is, believers should pray for other believers to be forgiven for 'sin not unto death'.1 They should do so in the confidence that God will forgive that other believer. That's a prayer 'according to his will'.
Theologians helpfully distinguish between God's will 'of decree' and 'of command'. That is, God wills us to live a certain way, his moral will, his will of command. But he also sovereignly ordains the providence of the world, which is his secret, decreed, sovereign will. All our prayers ought to be according to his moral will: we should pray for those things that he desires and wants us to have and to pray for. But not all our prayers are answered, because he has not so decreed.
That is a very short version of why we (a) don't know "the will" of God in terms of life's vicissitudes, and (b) why answers to our prayers that are 'no' and 'not yet' are the very answers we seek, "according to his will", even when we don't know that and don't like that.
The complexity of how prayer 'works', interacting with providence, free-will, God's will, and so on, is a complex web of difficult ideas. And this verse simultaneously comforts and confronts. It should comfort us, that God has already answered our prayers at the moment of their asking, with an answer according to his will, perfect and good. That means that I need to learn to accept that answer, and conform my will to his, whatever that answer is.
My view is that 'sin unto death' is the same as ἀνομία in 1 John 3:4, and is best understood as the sin of rejecting Jesus, because that is (a) rejecting the very means of forgiveness, (b) by definition something one cannot do and be a believer, because it means not being a believer.