Have you ever heard of the separation between church and state? In the middle ages this did not exist yet. The Pope was more powerful than the emperor.
Have you ever moved? Everyone is now free to live wherever they want. In history, you had to buy yourself free first if you wanted to live in the city.