Charlemagne was a devout christian. His goal was to thank God, he was set out to improve the church. The duty of the pope was to assist him.
You can not excommunicate me!
Yes I can, who said I can't excommunicate you!
Charlemagne believed that God had made him emperor in order to do God's work on Earth. It was the duty to assist him in that work. Pope Leo, however, believed that the church made him emperor.
In 1073, a monk named Hildebrand became Pope Gregory VI. Gregory had strong ideas about powers of the pope. He issued a list of rules declaring his supreme authority over both church and secular leader. Henry IV, the Holy Roman emperor, at the time, reacted to Gregory's new rules. They were a direct attack on his own power and rights.
The clash began when Henry ignored the pope's rules. and named his own bishop for the city of Milan, Italy. In response, Pope Gregory appointed a rival bishop. Next, Henry tried to remove Gregory as pope. Pope Gregory excommunicated Henry.
At the end across Europe, members of clergy secular and rulers took sides. The Concordat of Worms is an agreement that gave the Church a sole authority to appoint bishops. But it also allowed emperors to give fiefs, or grants of land to bishops in order to win their loyalty.
In the end, people took sides and that is how everything started.