First of all, it is not "confessing to a priest." It is confessing to Christ and to the community (the Church) and even all of creation. The priest merely represents the entire Christian community. Before the time of Constantine the Great, members of the Church confessed their sins to the entire church community to which they belonged. This was possible when churches were intimate small-ish communities who lived in fear of persecution and were thus tightly-knit groups. After the Church received official toleration and then great approval from the Roman Empire, She received converts en masse, and churches were no longer intimate little groups. I imagine it became unseemly and strange to confess your sins to crowds of strangers. Also, I suppose that many converts who joined the Church at this time may well have done so for, well, reasons that would have been unthinkable a few decades earlier. This would have made confessing to the entire community even more problematic. So the practice of having the priest "stand in" for the community dates from this time.
The Church is a physical and visible (as well as spiritual) entity, where everyone is in communion with everyone else. When we sin, we sin against God and all of our brothers and sisters and and all of creation, so it makes sense to ask forgiveness of the entire Body of Christ. The priest is given authority to pronounce forgiveness in the name of Christ and the community. So it is of course a great (one might say even necessary) thing to confess our sins to God in private prayer, but it is also necessary to confess them to the entire Christian community of which we are a part.
Another thing about confession is that over time it has become the method whereby many people receive the only (or at least the principle) spiritual direction that they will get, so it has become rather indispenible because of this also.