It has always been held by the Church that Jesus conferred the ability to forgive sins to his Apostles and subsequently they conferred this ability to their successors. We find this in scripture in John 20:21-23:

21 Jesus said to them again, “Peace be with you. As the Father has sent me, even so I send you.” 22 And when he had said this, he breathed on them, and said to them, “Receive the Holy Spirit. 23 If you forgive the sins of any, they are forgiven; if you retain the sins of any, they are retained.”

Saint Hippolytus of Rome plainly confirms this belief less than 200 years after the death of Christ:

“After this, one of the bishops present, at the request of all, laying his hand on him who is ordained bishop, shall pray this way: O God and Father of our Lord Jesus Christ…pour forth the power that is from you, of “the princely Spirit” that you delivered to your beloved Child, Jesus Christ, and that be bestowed on your holy apostles, who established the Church that hallows you everywhere, for the endless glory and praise of your name. Father, “who knows the hearts of all” grant this servant, who you have chosen for the episcopate, to feed your holy flock and serve as your high priest blamelessly night and day, and unceasingly turn away wrath from your face and offer to you gifts of the holy Church. And that by the high priestly Spirit he may have authority “to forgive sins” according to your command.” (Apostolic Tradition 2-3)

The Church teaches that “Christ instituted the sacrament of Penance for all sinful members of his Church: above all for those who, since Baptism, have fallen into grave sin, and have thus lost their baptismal grace and wounded ecclesial communion. “

Following the command of Christ, we are to seek out the successors of the Apostles (namely Bishops and Priests of the Catholic Church) and confess our sins to them so that we may remain in a state of Grace and receive God’s mercy through this Sacrament.