Back when the Papacy held temporal power in the form of the Papal States they were often at war with neighbouring monarchies. But the Pope was much more that just the monarch of the Papal States; he was the spiritual ruler of all of Europe, including the monarchs he fought against. You might think this would have caused quite the moral conundrum, but apparently Catholic kings had no problem at all fighting against their own religious leader.
The Holy Roman Emperors in particular were at war with the Popes throughout the Middle Ages. The staunchly Catholic Charles V, for example, fought and won wars both against his Protestant princes and the Pope, even sacking Rome in 1527. The modern Kingdom of Italy (even today one of the world's most thoroughly Catholic countries) was only created after King Victor Immanuel II conquered the Papal States. For this he was excommunicated, but was buried in a Catholic church nonetheless. I found this very confusing.
So why did the threat of excommunication not deter monarchs from antagonising the Pope? Did the office not have the respect and authority then that it had in more modern times? Was it simply seen as a temporal dispute and not a religious one?
I will begin with the micro, before I explore the larger view of the nature of the conflict imperial and pontifical in early modern europe.
As much as the image of the all-powerful Holy Roman Emperor Charles V -- the one and only to ever hold lordship over the Spains and her growing empire in the Americas and in the Mediterranean, the Holy Roman Empire, and that of Burgundian lands -- sacking the eternal city Rome over a feud with the Pope is very dramatic, the reality was .... dramatic but in very different ways than are popularly depicted.
As I have written here on r/EarlyModernEurope, to understand the Sack of Rome in 1527 we have to consider the Battle of Pavia two years prior, where a Spanish-Imperial army defeated the royal French army and captured King Francis I. Glorious as it was, the outcome of the Battle of Pavia was a great unexpected upset.
Even just moments leading into the battle, Charles V was in a weak position in the HRE and had scarcely an army in Italy as Francis I of France brought his army into the peninsula. In desperation, Charles asked his brother Ferdinand, regent in the HRE and Austria, to hire landsknechts under the legendary Georg Frundsberg. Moving quickly, he was able to send 15,000 of them south across the alps from Germany. Such a crossing was nowhere near the image of a perfect parade-day procession. Units large and small ambled their way across the alps, over days. Fortunately, they were able to surprise the French and defeat them decisively. Unfortunately, Charles did not yet have a mechanism to provide reliable funds to keep the army under control.
As a result, all of northern Italy quivered in fear as roaming bands of Spanish-Imperial units went from one city to another, threatening citizens lest they be paid off ransom and given riches. Only strong fortified cities were spared as this rabble knew they could not besiege strongholds. Cohesion broke down further and further as the army, led by the Charles of Bourbon and Georg Frundsberg, ambled its way down toward Rome in the early spring of 1527. Perhaps the term "led by" was used too generously, as these two commanders were held captive by their unpaid troops as much as they could impose any amount of discipline upon it.
Fearful for his safety and that of the Papal States, Pope Clement VII attempted to negotiate with Charles Lannoy, the viceroy of Naples. Lannoy negotiated a truce that included a mere 60,000 ducats of payment for a body of over 22,000 troops who had been unpaid for most of 1527, if not since 1526. Naturally, when it was found out by the army that only a small amount would be given, they were upset and chased Frundsberg off. They then forced Charles of Bourbon to lead them south toward Rome, to negotiate directly with the Pope. Bourbon announced that he could barely control the army that was at the brink of mutiny -- which would lead to an assault on Rome -- and asked for 240,000 ducats to appease them. Pope Clement balked, simultaneously begging rich citizens of Rome to spare some of their riches while trying to hire as many mercenaries as he could. In the end, he had several thousand soldiers to defend Rome against the horde.
Brave as they were, the Pope's soldiers were simply overcome by the marauders. It was a stiff fight, during which Bourbon was killed. His death erased any and all discipline, and restraint disappeared. The horde breached the city at multiple points and fought their way while plundering and murdering.
Charles V was utterly shocked when he heard what had happened. He apologized profusely, and he was roundly criticized for losing control over his troops.
How was the sack viewed in its time? Guicciardini, a political commentator, writes that the culture of lust, greed, and ambition of the papacy and of Rome's citizens had brought the just wrath of God that came upon them. His writing is hardly novel, as there had been a long tradition of apocalyptic writing criticizing the ills of Rome and of the various pontiffs. There were significant skepticism in both Rome and the Popes, that Rome was often referred to as Babylon. This was the line hewed by Charles' own propagandists, such as his secretary Valdes.
Continuing on this, I shall be amiss to not mention this excellent post by the esteemable u/AlviseFalier, which reviews how the Popes of the 1500s came to be that way, most importantly how they came to rule the Papal States. Most importantly, I quote:
Papacy holding temporal power was far from an irrevocable fact.
That, and the view of war from the perspective of Aquinas' Just War, are what justified the wars against the Pope in his role as ruler of the Papal States. Even as Charles issued his apologies, he cited the corruption of Rome in continuing his political pressure on the Pope to move away from his alliance with France and become his partner instead. There was even serious talk of forcing Clement VII to abdicate so that a more suitable candidate could become pope.
Such was the view on Papacy and its temporal powers in early modern europe.