Have you ever heard of the separation between Church and State? In the epoch of the middle ages this yet. The Pope was more powerful than the emperor.
In the medieval towns lived many craftsmen, such as carpenters, shoe makers and painters. People with the same craft joined a Guild. The Guild laid the craftsmen rules and obligations on, but helped if there were problems.
Are you ever move? Everyone is now free to live where he wants. In the history you had yourself first quite buy it if you wanted to live in the city.