Why was the church a stabalizing force during the midle ages?