Before delving into confession, keep in mind the following: Grace is what God does; faith and works are what the Christian, in response to God’s grace, does; baptism, which washes away sins and brings us into the body of Christ, is what the Church does.
If baptism forgives sins and reconciles us with Christ, how are we reconciled with Christ if/when we commit mortal sins (sins causing spiritual death; read 1 Jn 5:16-17 and Jas 1:13-16) after baptism? The answer is confession to a bishop/priest, a.k.a. auricular confession. If God works through the priest to forgive sins in baptism, he works through the priest to forgive sins in confession.
“The second precept [of the Catholic Church], ‘You shall confess your sins at least once a year,’ ensures preparation for the Eucharist by the reception of the sacrament of reconciliation, which continues baptism’s work of conversion and forgiveness” [emphasis added to show confession’s relation to baptism].
“Since Christ entrusted to his apostles the ministry of reconciliation (cf. Jn 20:21-23; 2 Cor 5:18), bishops, who are their successors, and priests, the bishops’ collaborators, continue to exercise this ministry.”
Jesus Gives His Authority To the Apostles
At Pentecost Jesus said to the ten apostles (ten because Judas had already committed suicide and Thomas was absent), “‘As the Father has sent me, even so I send you.’ And when he had said this, he breathed on them and said, ‘Receive the Holy Spirit. If you forgive the sins of any, they are forgiven; if you retain the sins of any, they are retained.’”
First, how did the Father send Jesus? He sent him with authority. “And Jesus came and said to them, ‘All authority in heaven and on earth has been given to me. Go therefore and make disciples of all nations, baptizing them in the name of the Father and of the Son and of the Holy Spirit, and teaching them to obey everything that I have commanded you. And remember, I am with you always, to the end of the age’” (Mt 28:18-20).
Second, Jesus breathed on the disciples. God breathing on man happened only one other time in scripture when God breathed on Adam (Gen 2:7) to give him life, a life that had authority over creation. By breathing on the apostles, Jesus gave them the authority to restore spiritual life. Notice Jesus gives the apostles authority to forgive and retain sins. How would they know which sins to forgive or retain if others did not confess their sins to them?
Separation and Reconciliation
When a person commits mortal sin, they intentionally separate themselves from Christ and His Church by rejecting the very grace that brought them into communion with both. By choosing to leave Christ and His Church through sin, they have to be reconciled to both. And auricular confession is how the Church, the body of Christ, reconciles the wayward sinner.
Justification is a lifelong process that begins with baptism. We are initially justified by grace through faith and baptism at a particular point in our lives. After we are justified, we continue in this state by obedience to God. If we mortally sin by purposely disobeying God, we enter a state of spiritual death. When in a state of spiritual death, the only way to be reconciled to God and the Church is by real contrition and confession to a priest.
 CCC, 2042.
 CCC, 1461.