Pope Leo III came to Charlemagne from Rome for protection after a threat. In reward they traveled back to Rome and he crowned Charlemagne with the title of emperor. As emperor, Charlemagne wanted to improve the church and enforce Christian rules.
I have power!
This infuriated the Byzantine Emperor and was seen as an insult to him. He didn't agree that a pope could crown an emperor. It later led to the division of the Eastern and Western Church.
You're no longer Pope!
You're excommunicated from the church!
Charlemagne believed that God made him the emperor, but the Pope thought the church was responsible. This started a conflict between the kings and popes. There are several other reasons that they kept fighting.
In 1073, Pope Gregory made a list of rules. He declared authority over Church and secular (non Church) leaders. He was the only one who could appoint bishops, and could remove a king from his power
King Henry ignored these rules and appointed a bishop for the city Milan. In return, Gregory named a rival bishop. Then Henry tried to remove Gregory as Pope, but pope Gregory excommunicated Henry.
King Henry then marched in with his army and forced Pope Gregory to resign as Pope. Later, the Concordat of worms was signed. It said that the Church appointed bishops, the King could grant fiefs to earn the bishops' loyalty, and more.