The Catholic Church’s technical introduction to politics was in 315, when it was legalized. By 400, it was the state religion, which brought it a step closer. Its priests and bishops had the ear of the emperors. As far as I am aware, though, the Church gained little from the relationship – in some places (the East), the bishops allowed themselves to become subject to the political authority. In others, the Church excommunicated authorities for perpetrating massacres and such, and harangued them for their riches in a world with so many poor.
When Rome fell in 453, it left an enormous power vacuum in the West – perhaps the largest in history. The Church, led especially by Pope Gregory the Great, was left as literally the only active authority in the area. (Technically, the West was still under the protection of Constantinople, but the only thing Constantinople cared about was Italian taxes – they otherwise left the West largely to the barbarians.) The Church had spiritual authority. It had great wealth, donated over the preceding centuries by nobles, who left their estates to the Church in many cases. And now suddenly the welfare of Rome and the surrounding area was pretty much the responsibility of the only institution that could protect the innocent: the Catholic Church.
By the 700’s and 800’s, the age of kings was dawning. Rome, threatened by pirates and Muslim invaders (who were marching through Italy, raping and pillaging, despite the best efforts of Papal forces), allied itself with kings like Charlemange, granting them recognition as legitimate successors to the emperors in exchange for protection.
This is when the corruption really got started. The Pope suddenly was playing as a major world political power. That made his position not just one of faithful servantship to his flock (in his role as bishop of Rome), but also an immensely powerful, immensely wealthy position. That attracted all the worst kinds of people to the job. We saw the great debasements of the Pornocracy; of the Medicis; of the Papal invasions and wars. Remarkably, the Church still did fairly well, especially compared to the rest of Europe (we held the line in the investiture controversy, which was nothing short of miraculous), but this was the golden age for the Church’s secular power.
It really ended with the Reformation. It took a few generations for it to sink in, but after Luther the Popes were never really able to exercise their dramatic spiritual/temporal power on a global scale again. They became administrators and leaders of the Papal States. Their allies among the Kings still functioned on behalf of the Faith, but rarely in close conjunction with the actual institutional Church. Cardinals were still wealthy and powerful and deeply involved with politics, but after the Reformation the structure started degrading quite quickly. The Enlightenment put much of the respect for the Church, even in the remaining Catholic countries, to flame. France effectively seceded from the Institutional Church in its 1789 revolution. And the Papal States themselves finally fell in Garibaldi’s invasion in the mid-1800’s.
The total de-secularization of the institutional Church – except for Vatican City, which exists only to ensure that the Pope is never subject to the authority of any temporal power (which might try to coerce the Pope, which would be disastrous) – came during the papacy of John Paul II, which issued and enforced a directive ordering all ordained persons to exit political life.
Source: a detailed class on the History of Rome, 315 - 1650, a class on the Church and Europe, 1789 - Present, and a lot of independent reading of my own.
Hope that helps.