the church gained power in the middle ages because: