I would suggest reading Hilairre Belloc’s book “Europe and the Faith” to understand Europe of the middle ages.
The Roman Empire in the west did not “fall” in the sense that we commonly thing. Due to continual civil wars between armies of Rome (the so called "barbarian invations) the central government from Rome broke down. People throughout Western Europe would have still thought of themselves as part of the Roman civilization, which became increasingly identified with the Church. As Bello said “The Church was Europe, Europe was the Church”. All of the local kings would have thought themselves subservient to the Roman Emporer in the East, but due to the failure of communications, this became more and more an abstraction. The Pope, as the head of the Church, was looked at as the head of Europe. People would not have thought themselves French, or Spaniards, or Gauls, they would have identified themselves based on the local area the lived in or as members of Christendom, which the Pope was the head.
So the crowning of Charlemagne was very much though of as a restoration of the Western Empire and it would have been only natural for the Pope to crown him.
The fact that the Kings and Emporers wanted to invest their own bishops highlights the fact that the separation of the temporal and ecclesiastic was not as well defined a conflict as we have today.