There were popes who were more licentious than any immoral ruler and who made their illicit sons the next popes. At other times they were merely puppets at the hands of emperors and kings who made many they wanted as popes.
The Roman Church had become wealthy and strong by the 8th century. Popes became imperious and acted with high-handedness. Many popes were from wealthy aristocratic families and they increased the wealth of the Church by demanding gifts in return for prayer and mass for the dead. The Church by AD 800 had become the greatest landowner of Europe. The papacy of the Roman Catholic Church fell under the influence of harlots and this era is generally termed pornocracy (the rule of the harlots). Pornocracy or the more polite Saeculum obscurum (Latin for the Dark Age) began in 904 AD with the installation of Pope Sergius III. The Pope was completely under the control of Theodora, the beautiful wife of Roman consul Theophylactus, who used sex to wield power. Theodora's 15-year-old daughter Morazia became the concubine of Pope Sergius III. Their illegitimate son later became Pope John XI. The era of Pornocracy ended with Pope John XII (the grandson of Marozia) in 963. He was so immoral that the Basilica of Rome was converted into a brothel under his rule. The luxurious Vatican palace had become a place of orgies and degradation. Prostitutes were welcome in the palace and the popes became licentious and drunken revels.
Pope becomes a puppet of Kings
Otto the Great, German king from 936 and emperor of the Holy Roman Empire from 962 until his death in 973, chose his own popes. During the reign of John XIII he took full control of the papacy and the Pope could do nothing about it. He appropriated the right for papal and higher clergy nominations and he selected popes and bishops and cardinals. They were not holy at all. As a large part of the land was owned by bishops and abbots, landlords got easily into these positions. Anyone could be made a bishop or a priest, if these powerful people wanted, without ordination or consecration. The next emperor, Henry III had deposed three rival popes. Over the next ten years he personally selected four of the next five pontiffs.
By the 13th century papacy acquired immense power. Popes introduced a method of nomination of bishops and other ecclesiastical authorities for which a fee was levied. A complicated and oppressive system of taxation was devised with a large number of papal officials sent everywhere demanding money. King Philip of France, being offended by such greedy plans of the Pope, determined to seize for himself the revenues of the Church and to impose heavy taxes. Pope Boniface VIII who was elected pope in 1294 argued strongly with the king and excommunicated him in 1303. To assert his authority, King Philip brought papacy under the domination of France. He defied the Pope with impunity. Philip elected a Frenchman as Pope Clement V and made him take up residence at Avignon in 1309 in the south of France. He made nine French cardinals. Aside from Clement V, there were six other popes in Avignon. They were Pope John XXII from 1316-1334, Pope Benedict XII from 1334 to 1342, Pope Clement VI from 1342 to 1352, Pope Innocent VI from 1352 to 1362, Pope Urban V from 1362 to 1370 and Pope Gregory XI from 1370 to 1378. After a few years, persuaded by a pious nun, Pope Gregory returned to Rome. It was through a great effort that the Church slowly regained its ecclesiastical powers.
How can then papacy be a divinely instituted thing?