I heard the Bible was oral history for a long time before it was written. Why was it written? Is there any record of the circumstances?
The transition of the Biblical narratives from oral traditions to written documents is complicated and the process is highly debatable, both with the New Testament but especially with the Hebrew Bible. The preservation of the Israelites' national myths, and later on the life of Jesus for his followers, had an obvious purpose of ensuring that subsequent generations had access to these stories and traditions, but the putting of these into writing also allowed for the preservation of the authors' theological interpretations of these stories. This is especially relevant for the New Testament.
Most scholars believe that the main impetus for the growth of early Christian literary texts from the late first century onwards was the dying off of those followers who had known Jesus in his lifetime. As members of the Jesus movement realized that his return was not coming as imminently as they had anticipated, the need to preserve his teachings for future followers, as well as new converts to the movement, became an important issue. Thus we have the arrival of texts such as the Q Gospel (and perhaps also an early form of Thomas) as collections of teachings attributed to Jesus. But when we get to the four canonical gospels, we can see that the putting of these oral traditions into writing also allowed the authors to present to readers an interpretation of these events from their own theological perspective. For example, in Mark we see the author frame the story of Jesus in such a way as to demonstrate to readers how Jesus differed from traditional notions of the Jewish messiah; in Matthew the author casts Jesus as a new Moses, using prophecies from the Hebrew Bible to argue to Jewish readers that Jesus has been foretold in scripture; Luke organizes the narrative of his gospel and Acts to show the universality of Jesus' message, which has been proclaimed to the Jews and is now being taught to the Gentiles; and John uses his gospel to teach in explicit terms the divinity of Jesus and his oneness with God. Thus, in addition to preserving Jesus' teachings for generations of Christians who did not know him in his lifetime, the transition from oral traditions to written texts allowed for Jesus' story to be preserved in a way that also taught the theology of those who wrote them. By controlling the narrative of Jesus that would be handed down to subsequent disciples, the authors of these written texts were able by extension to shape how people would interpret Jesus in generations to come. One needs look no further than John's gospel to see how great an effect this could have. What eventually became orthodox Christology, with a belief in the divinity of Christ and his timeless unity with God the Father, relies predominantly on the depiction of Jesus in the Gospel of John. The transition of oral traditions into written texts has enormous influence on how future generations understand the events they describe.