2541 Thirdly, we see the fruit of the gift, If you forgive the sins of any, they are forgiven. This forgiving of sins is a fitting effect of the Holy Spirit. This is so because the Holy Spirit is charity, love, and through the Holy Spirit love is given to us: "God's love has been poured into our hearts through the Holy Spirit which has been given to us" (Rom 5:5). Now it is only through love that sins are forgiven, for "Love covers all offenses" (Prv 10:12); "Love covers a multitude of sins" (1 Pet 4:8).
2542 We can ask here why we read, If you forgive the sins of any, for only God forgives s...ins? Some say that only God forgives the sin, while the priest absolves only from the debt of punishment, and pronounces the person free from the stain of sin. This is not true: for the sacrament of Penance, since it is a sacrament of the New Law, gives grace, as does Baptism. Now in the sacrament of Baptism, the priest baptizes as an instrument, and yet he confers grace. It is similar in the sacrament of Penance, the priest absolves from the sin and the punishment as a minister and sacramentally, insofar as he administers the sacrament in which sins are forgiven. The statement that God alone forgives sins authoritatively is true. So also, only God baptizes, but the priest is the minister, as was said.
2543 Another question arises from the statements, Receive the Holy Spirit. If you forgive the sins of any, they are forgiven. It seems from this that one who does not have the Holy Spirit cannot forgive sins. We should say about this that if the forgiveness of sins was the personal work of the priest, that is, that he did this by his own power, he could not sanctify anyone unless he himself were holy. But the forgiveness of sins is the personal work of God, who forgives sins by his own power and authority. The priest is only the instrument. Therefore, just as a master, through his servant and minister, whether good or bad, can accomplish what he wills, so our Lord, through his ministers, even if they are evil, can confer the sacraments, in which grace is given.
2544 Again, there is a question about, If you forgive the sins of any, they are forgiven. We should say, as we already did, that in the sacraments the priest acts as a minister: "This is how one should regard us, as servants [ministers] of Christ and stewards of the mysteries of God" (1 Cor 4:1). Thus, in the same way that God forgives and retains sins, so also does the priest. Now God forgives sins by giving grace, and he is said to retain by not giving grace because of some obstacle in the one who is to receive it. So also the minister forgives sins, insofar as he dispenses a sacrament of the Church, and he retains insofar as he accounts someone unworthy to receive the sacrament.
Source: Commentary on John