In the game Crusader Kings II, playing as one of the medieval pagan factions gives you the ahistorical option of reforming their religion into a more oraginised and centralised verion, in order to counteract the growing influence of Christianity/Islam.
While I know that this is just entertaining fiction, are there any examples at all of something similar happening in real life? Are there any historical examples of pagans taking a vague set of folk beliefs and turning them into a proper church, or something like it? If so, what was the imperative to do so?
The Roman emperor Julian tried to reform Hellenistic polytheism to better counter Christianity, though his efforts failed and he was to be the last Hellenic emperor. Julian had a Christian upbringing but secretly embraced paganism as a young man, and he openly announced his religion upon usurping the throne of his cousin Constantius.
Julian enacted a number of reforms to restore paganism as the state religion. He guaranteed religious freedom, but also attempted to better order and standardize classical religion and stop Christianity's encroaching influence. Unfortunately for him, his efforts failed to revitalize the population much, though perhaps his most cunning move was to forbid Christian teachers from using classical texts like the Illiad, which meant that students went instead to pagan teachers. He also did his best to foster rivalry between the various Christian factions and disorganize and weaken the church as much as possible.
Julian was a good administrator, a military genius, and in sum a capable, intelligent, and well-meaning emperor. However he was also a bit of a mystic and fell under the sway of a number of magicians and schlocks that undermined his image. He was killed in battle invading Sassanid Persia in 363, and his successor was a Christian.
Julian's religious views were rather interesting and influenced by his Christian upbringing. Occasionally it's said that he was essentially molding classical polytheism into a monotheistic model. Julian was a neo-Platonist and believed that there was, ultimately, one divine being or influence. Essentially, Julian attempted to reform paganism, an unorganized and syncretic system of many different beliefs bound together by religious tolerance, into a unified structure that could hold it's own against the advance of monotheism.