This is sometimes called the Office of the Keys or the Power of the Keys. It's the authority Jesus gives to His Church, as His ambassadors, to proclaim forgiveness or withhold forgiveness.
This is our Lord's promise to His Church: "Peace be with you. As the Father has sent me, even so I am sending you. Receive the Holy Spirit. If you forgive the sins of any, they are forgiven them; if you withhold forgiveness from any, it is withheld."
Although this is a descriptive text, a recorded history, and not a prescriptive text, we can know from other Bible passages that this is God's gift to His whole Church, not just His disciples. For in Christ, we have peace with God and we are graciously given the Holy Spirit, and we become the ambassadors of Christ to proclaim the Gospel. So, this is to say, we are called to proclaim God's forgiveness to those who repent, but to withhold the Gospel from those who refuse to repent.
In practice, this is what the historical church bodies call Confession and Absolution, and since late New Testament time, we find this practised both publically and privately. And although throughout history, there has been a lot of debate about to whom our Lord grants this authority, at its heart, the idea is the same: God, in His great love and mercy, promises to forgive us in many ways, and one of these ways is through His people. Likewise, He also grants repentance through His people, by means of His Word.
So to put this very simply: When I grew up as a Pentecostal, I used to think Confession was something entirely man-made and contrary to the Bible. However, to my shame, it's taught very plainly in John 20, and properly understood, it's really a matter of repentance and faith. And to your question, while this passage is not about angels or demons directly, it does have indirect applications. However, I think this is easiest understood to be about comforting people who are burdened with sin with the peace of Christ, and withholding the peace of Christ from those who reject Jesus.
God bless!