Some of the Roman Emperors feared the Christian movement and attempted to snuff parts of it out. Charlemagne, however, admired the Church for its organizational and administrative skills and sought to harness that for the benefit of his somewhat shaky Empire. Christianity wasn't exactly made the State religion but it certainly had preferential status, protection and favor from the Emperor for the first time in Church history which allowed it to become firmly established and a force to reckon with throughout almost all of what is now Europe, the near East, southern Africa.
Part of God's overall plan for the Church? That is on my list of questions I hope to take with me.
The Church was not able to save the Empire though and as it crumbled and new monarchs started cropping up, they often worked hand in hand with the hierarchy of the Church essentially co-ruling in places that would become new nations. IMO, most of the popes during the Middle Ages were pretty much self serving and did little or nothing to either reform, sustain, or advance the Church. So we had several hundred years of truly 'dark ages' in the Roman Catholic Church despite several bright spots in both architecture and institutions that were formed.
And still the Church remained. The Renaissance helped in restoring interest in the classical literature/manuscripts of the early Church even as Martin Luther's rebellion unintentionally created the Protestant movement. (Luther never intended to leave the Roman Catholic Church but intended to reform it. And in fact, even as Protestantism blossomed, the Roman Church did reform and revitalized itself with new energy, influence, and power.)
This is a long way of saying that 60 years of bad popes is neither unprecedented nor unusual in the long history of the Church, nor is scandal or hard times. But the Church is still with us. Things seem dark now, but I think we are ready for a new revival. I hope so.