Generally speaking, rulers throughout history have used religion to add a touch of spiritual legitimacy to their rule. Think of it this way, if it's widely believed that a king or queen has been appointed by God, that makes it so much more difficult to challenge them. After all, in such a political environment, by challenging the ruler you're also challenging God, and that's not just treason, but blasphemy.
For several hundred years in Europe, the dominant idea in political philosophy was the Divine Right of Kings. This held that rulers had been chosen by God and were therefore entitled to rule as of right. It didn't matter what their subjects thought, kings and queens were appointed by God and, as such, were answerable to him and him alone. Just as God in his divine wisdom had decided who should rule, he should also be the one to decide when they stopped ruling, when he would strike them dead. No one else had the right to determine the length of a monarch's reign; it was God's will and God's will alone.
State religions such as the Church of England were used to buttress the monarch's temporal power and authority. Ministers would preach loyalty to the king or queen from their pulpits every Sunday, warning their parishioners of the terrible consequences that would follow from treason and sedition, not just upon this earth but in the afterlife. Virtually everyone at that time believed in God and the literal existence of heaven and hell, so this was a powerfully persuasive message. The Church could use its spiritual authority to cow a monarch's subjects into submission, thus cementing the alliance between Church and state and maintaining the power and authority of both, not to mention strengthening the rigid social hierarchy on which they were based.