So when did this idea that a scripture or a prophet or a messenger or a pope is absolutely perfect in every way come into practice? Has it been there since early times, or is it more recent? What purpose does it serve?
That's a great question. Not sure if there is any one simple answer, but I was just discussing this with someone yesterday and here are a few of the thoughts we shared. I believe this relates to what is recognized as within the cognitive behavioral sciences as the "strict parent vs nurturant parent" upbringing. In this article discussing the basis behind why a Donald Trump was nominated as the Republican nominee (old article), he goes in some things I think relates to your question.
Understanding Trump
"The conservative and progressive worldviews dividing our country can most readily be understood in terms of moral worldviews that are encapsulated in two very different common forms of family life: The Nurturant Parent family (progressive) and the Strict Father family (conservative).
What do social issues and the politics have to do with the family? We are first governed in our families, and so we grow up understanding governing institutions in terms of the governing systems of families.
In the strict father family, father knows best. He knows right from wrong and has the ultimate authority to make sure his children and his spouse do what he says, which is taken to be what is right. Many conservative spouses accept this worldview, uphold the father’s authority, and are strict in those realms of family life that they are in charge of. When his children disobey, it is his moral duty to punish them painfully enough so that, to avoid punishment, they will obey him (do what is right) and not just do what feels good."
He then goes on to talk about the differences in how conservatives tend to see things in terms of direct causation versus systemic causation:
"Direct causation is dealing with a problem via direct action. Systemic causation recognizes that many problems arise from the system they are in and must be dealt with via systemic causation. Systemic causation has four versions: A chain of direct causes. Interacting direct causes (or chains of direct causes). Feedback loops. And probabilistic causes. Systemic causation in global warming explains why global warming over the Pacific can produce huge snowstorms in Washington DC: masses of highly energized water molecules evaporate over the Pacific, blow to the Northeast and over the North Pole and come down in winter over the East coast and parts of the Midwest as masses of snow. Systemic causation has chains of direct causes, interacting causes, feedback loops, and probabilistic causes — often combined.
Direct causation is easy to understand, and appears to be represented in the grammars of all languages around the world. Systemic causation is more complex and is not represented in the grammar of any language. It just has to be learned.
Empirical research has shown that conservatives tend to reason with direct causation and that progressives have a much easier time reasoning with systemic causation. The reason is thought to be that, in the strict father model, the father expects the child or spouse to respond directly to an order and that refusal should be punished as swiftly and directly as possible."
So we see in this reasons behind why someone is more attracted to thinking that supports an external authority. You must follow the rules, they need to be clear, they will be enforced, you must get it right! It really seems a case of how we may have been raised. In the Nurturant Parent family, there is a openness to finding answers from an array of available option encouraging us to explore possibilities.
An external authority, who you can then defend as being "infallible", takes the responsibility off yourself to figure it out. "They tell me what to do. I do it. I'm good." Or in a saying I've heard from many Biblical Infallibility apologists, "God said it. I believe it. That settles it for me!". It's the same thing. You're OK if you just obey what you believe to be the truth. It does not require you to find answers from within yourself. It is not messy. It's not full of "what if I get it wrong" questions and concerns, etc. It's easy and safe.