Midrash is an interpretive act, seeking the answers to religious questions (both practical and theological) by plumbing the meaning of the words of the Torah.
(In the Bible, the root d-r-sh is used to mean inquiring into any matter, including occasionally to seek out God’s word.) Midrash responds to contemporary problems and crafts new stories, making connections between new Jewish realities and the unchanging biblical text.
Midrash falls into two categories.When the subject is law and religious practice (halakhah), it is called midrash halakhah. Midrash aggadah, on the other hand, interprets biblical narrative, exploring questions of ethics or theology, or creating homilies and parables based on the text. (Aggadah means"telling”; any midrash which is not halakhic falls into this category.)
It is often difficult to determine, simply from reading the biblical text, what Jewish law would be in practice. The text of the Torah is often general or ambiguous when presenting laws. Midrash halakhah attempts to clarify or extend a law beyond the conditions assumed in the Bible, and to make connections between current practice and the biblical text. It made possible the creation and acceptance of new liturgies and rituals which de facto replaced sacrificial worship after the fall of the Second Temple, and the maintenance of continuity by linking those practices to the words of the Torah.
Midrash halakhah from the two centuries following the fall of the Temple was collected in three books--the Mekhilta on Exodus, the Sifra on Leviticus, and the Sifrei on Numbers and Deuteronomy--known as the tannaitic midrashim.(The tannaim were the rabbis from the time of the Mishnah, edited in approximately 200 C.E.)