Early Jewish commentary on scripture. The purpose is to bring it up to date for readers of each generation; it is a kind of interpretation, and also a work of reconciliation—explaining an original narrative by the insights of a later age. Thus, in 2 Sam. (24: 1) it is said that God, in anger, incited David to take a census of the people, for which David, or rather the people, were punished by a pestilence (2 Sam. 24: 15). But by the time of 1 Chron. (21: 1) the proposal is said to be imparted to David by Satan, which is more in tune with the theology of the Chronicler.
In the Qumran community the narratives of the OT were retold and the commentators composed stories based on them, in the manner of preachers. Paul explains in 1 Cor. 10: 11 that scripture has, over and above its original meaning, a derivative meaning, applicable to his own day, which he endeavours to tease out.
In the gospels Matthew is particularly adept with the midrashic method. Much of this gospel is a rewriting of Mark, using the methods of midrash, but in the case of the infancy narratives, where he had no predecessor, Matthew uses a variety of OT texts to expound his belief about Jesus as the Christ. Events of the OT that happened to Moses and David, among others, are repeated in Jesus, who is thus the New Moses destined to lead his people into a new Promised Land. The genealogy established that Jesus was of the house of David—a ‘Son of David’ was part of Messianic expectation. These narratives are not therefore historical in the modern sense, though they contain historical material.