According to a book on this topic I have recently read, The Case for Clerical Celibacy: Its Historical Development and Theological Foundations by Alphonso Maria Stickler, there were two forms of celibacy up to 16th century and the Tridentine council: one is the "modern" as we know it now - priest can't be married. The second, older form was for married men who became priests: they were not allowed to have sex with their wife any more (with her agreement, off course). Some church fathers wrote that the wife became a "sister" of her husband. This older form of celibacy is recorded from several sources from fourth century on, mostly in "it was like this always since the apostles" manner. Such a rule have been explicitly written in fourth century AD, but wide agreement between bishops throughout the world (as was known then) shows it wasn't something new, just a reminder of sanctions emphasizing a part of spoken tradition.
At least since the fourth century, there were always some criticisms of this practice, often based on Bible. Some of the responses should be clear from my first paragraph: Peter had a wife, but he abandoned everything and she was no exception. Later, Paul in 1Corinthians 9:5 references Peter's wife, but Stickler says that the original Greek word there means "sister" rather than "wife" (I didn't check it, but I asked the more competent to approve or disapprove this claim on Bible hermeneutics) - this would fit that "no sex after ordination" model.
The "husband of one wife" part was interpreted in following way: if a man have remarried after death of his first wife, he proved he wouldn't be able to live in celibacy, so he's not a good candidate for priestly ordination.
Ability to raise children is essential, but in a way completely different from how we usually understand it. The meaning of celibacy has more layers, but spritual fatherhood is one of the most important. It's the priest's job to "bear" new Christians through preaching gospel (both to Christians and to others, who may convert through it), baptism and guiding others so that they became "spiritually adult". Like Paul sometimes addressed some of those who converted after his preaching "my son" (e.g. 1Timothy 1:2) and John called them "my dear children" (e.g. 1 John 2:1), every priest should guide others as a father guides his children (title "father" for addressing priests doesn't aim to decrease the importance of our heavenly Father, but should remind the priest his responsibility).
Having some children before ordination might help in this role (though it's not necessary - apostle Paul wasn't a father in worldly sense of this word, but he had more spiritual children than anyone except for Jesus), but knowing that I won't have any more children except for the spiritual ones is a strong motivation to try hard to do my evangelisation and pastoration well.
Also, having few tens or even hundreds of potential spiritual children, it's hard to take care of the biological children well too. Or, better: raising biological children takes significant amount of time, and the spiritual familly (usually a parish) needs another lots of time, which might take more than 24 hours a day together.
Imitating Christ, who didn't have a wife, at least according to mainstream Christianity beliefs, is another important aspect. The service of the priest is derived of the Last Supper - the priest have the power to act on Christ sake ("in persona Christi" - literally "in Christ's person"), especially during Eucharistic celebration. No man can merit such a grace, but the priest should try to be as close to the ideal of "a second Christ" ("alter Christus"). Priestly orders by itself won't change anyone from a weak sinner to a saint, and even though God's grace can make it, human collaboration is needed too.
As Paul wrote in 1Corinthians 7:32-34, having no wife can save a lot of time and energy for prayer and service. It also means a great motivation: I can either come to Jesus and find source of love in Him, or suffer and eventually burn out; I can't rely on my wife. Having no one except of Jesus helps to rely on Him a lot, and this is something a good priest needs.
A married man is a sign of Christ loving His Church (see Ephesians 5:21-33), but a priest living in celibacy can make this even clearer: a priest should imitate Christ especially in his love for Church, in His love that gives oneself, in His love of a good shepherd ready to lay down His life for His sheep. A married man should love God above all, but his wife is number two. For a priest, number two should be the Church - not through just one woman, but through every sheep of Lord's flock.
In Antiquity, the main argument against celibacy of priests was that Old Testament Levite priests had to be married, and they abstained from sex only for the days they actually served in the Temple. But a priest of the New Covenant serves eight pardon seven days a week, 24 hours a day (by prayer, mostly, though Eucharist is his primary duty) - so the priestly celibacy has no breaks allowing sexual life. The Eastern Christians (the Orthodox) first returned to the Old Testament style and stated that the priest should abstain from sex only on Sunday, but then they started celebrating Holy Liturgy on other days without requiring sexual abstination on these days.
Roman Catholic Church tolerates this practice for priests of Eastern rite, both Catholic and Orthodox, and this precedent is applied to other preachers who enter Catholic Church from traditions that abandoned celibacy (though bishops must live in celibacy, with no exceptions AFAIK).
Just a note in the end, celibacy of priests was never pronounced a dogma, but the reason is mostly that it belongs more to discipline than to doctrine, not that celibacy is not important.
In general, most strict and "harsh" practices of Catholic discipline are based on assumption that if we do what God ordered us to do (and we believe celibacy of priests is a part of this), Holy Spirit will help us to make what might be impossible without His help. There always are those who can't obey the rules, but the right solution is not to loose the rules but to pray harder to empower our faith in God's help.