There are a number of reasons.
The most important reason is that Jesus instituted the sacrament of confession as the primary method for our sins to be forgiven. After He rose from the dead, on Easter Sunday evening, He appeared to the Eleven and right away gave them the key to unbind sins. This was understood by the Church since the Apostles’ time to be the authority to absolve sins. No mere human can absolve sins, only God can. This authority was given by Jesus to his Apostles, who in turn pass on to the bishops and priests, down to our days.
Another aspect to consider is that when we sin, even the most private ones in our mind that we did not carry out in action, we always sin against God, ourselves, others and the whole creation.
We sin against God because we oppose to God’s Will. His commandments are not a restriction, but the safeguard that ourselves and all His created goods may not be harmed, but be blessed.
And therefore every time we sin, we also sin against ourselves as we are also refusing God’s blessing, and condemning ourselves by cutting ourselves off from grace.
We also sin against others and God’s creation, since we are made to be a blessing to others and the whole world. But when we sin, we remove ourselves from that grace and so at the least we would deprive that blessing that we are supposed to give to others, if not further compounded by the harm we caused directly by our sinful actions.
So, although it is true that one may receive forgiveness from God by making a genuine act of contrition directly to God, we still need to go to confession, especially for mortal sins, in order to obtain forgiveness for the harm we caused on others, the Church and the world. That is the absolution that is reserved to God, which He in turn delegated to His bishops and priests.
To illustrate, suppose I held a grudge against somebody but never acted on it. I can feel bad about it and in my own private prayer ask for forgiveness. But my private sinful thoughts also deprived me of my usual joyful self. I became more easily irritated, more judgemental and demanding, less prayerful and compassionate. All these in concrete ways make me less a blessing to everyone I encounter, and deposes me to be more self-absorbed, more prone to other sins. I need not only to mend my relationship with God, but also my relationship with others and the world that comes from the grace of absolution.
Another problem with forgiveness apart from confession, is that it is not public. Let’s face it: we are not trustworthy; we need to be held accountable. The confessional is a sealed public tribunal before God and His witness (the priest), where by confessing our sins openly, we are not informing God or the priest, but rather we are declaring war against our sins and so in the name of Jesus renouncing them. The power of that renunciation is real, since we are children of God and so our words carry the authority of our Father in heaven. Confession therefore is as much God freeing us from sin, as we ourselves participating in that deliverance by exercising our sonship and daughtership.
Lastly, being a sacrament, it is Jesus Himself who is administering it through the priest. Jesus Himself pronounces over us “I absolve you… your sins are forgiven”, and Jesus Himself blessing us. There are therefore extra graces only available here for the battle against those sins confessed in sacramental confession.