I started David Weiss Halivni's Peshat and Derash: Plain and Applied Meaning in Rabbinic Exegesis. Peshat and Derash are two methods of rabbinic exegesis, and medieval exegetes practiced their own form of peshat. On page 128, Halivni defines "peshat" as "the strict philological and syntactical meaning of a verse", and as "the plain meaning of a verse that is dictated by its content and context". Derash, by contrast, is applied exegesis. According to Halivni, derash "sometimes seems only loosely connected to the text" (page 128).
But identifying peshat as opposed to derash is not necessarily easy. Many have defined peshat as the literal meaning of the text, but what if the text was intended to be figurative? What is its plain sense then? For example, ancient rabbis have interpreted Deuteronomy 6:8---which exhorts the Israelites to bind the commandments on their hands and their foreheads---as literal boxes (tefillin), even though it's obvious to Halivni that Deuteronomy 6:8 is being metaphorical. Maimonides interprets Leviticus 19:14---"You shall not put a stumblingblock before the blind"---to mean that one shouldn't "give false advice to an ignorant person" (Halivni's words on page 88), and Maimonides actually regards that as the text's plain sense! The rabbis refer to interpretations of the Torah by the Sadduccees and the Samaritans that are in accordance with the text's plain, contextual meaning. And yet, Leviticus 16:2 says "for I appear in the cloud upon the ark cover", and the Sadduccees interpret that in light of the cloud of incense burned on Yom Kippur. Rashi calls that interpretation "derash", but Halivni notes that the rabbis before him did not see it as such. In this case, what was derash to Rashi was not derash in the eyes of the rabbis.
So what is the "plain sense"? Perhaps it varies according to the time period. Halivni offers a pretty solid case that the Amoraic rabbis regarded the peshat as the contextual meaning---the meaning that a passage has in light of its literary context (and yet see here). So maybe "derash" is more of an atomistic approach to the text, one that interprets a verse without regard to its context. There are times when the text is interpreted in reference to people, places, and things that are not in the text's immediate context, and that could be derash. And yet, regarding peshat, what we regard as the plain sense may not be what the ancients regarded as the plain sense, even though there might be overlap.
So the definition of these terms is one issue with which Halivni wrestles. But another issue he addresses appears to be what Jews should do in response to the flux of history. The flux of history shows that the rabbis' interpretations of Scripture were not necessarily true to what the Scriptures actually meant---even though they might have thought that they were being faithful to it, and medieval Jews struggled to defend the rabbis on this point. Moreover, halakah changes. Rabbi Yose said Jews could eat chicken and milk together, but his position was nullified a few generations later. Halivni may be searching for some basis for Jews to observe the halakah and to honor the rabbis, even though modern scholarship appears to undercut their authority by showing either how their understandings were inaccurate, or how Judaism has changed over the years, calling into question any notion that Judaism reflects the timeless will of God.
Halivni draws on different aspects of Jewish tradition to argue that Jews should still observe halakah, notwithstanding the insights of modern scholarship. He quotes a rabbinic passage affirming that God is not concerned about Jewish observance of halakah, but halakah is intended to refine the Jews. Halivni interprets that to mean that the struggle to arrive at halakah is a refining process. Halivni also notes that, on the basis of Exodus 23:2, the Talmudic rabbis upheld majority rule (with some exceptions), even in a story in which God sided with the minority opinion. Yet, the rabbis also preserved and respected the minority opinions for intellectual purposes. (Exodus 23:2 was understood by them to mean that "after the majority one must incline", but many English translations understand the verse to be saying that one should not follow the majority to do evil.) And, in one rabbinic tradition, God revealed different points of view, but not the resolution, and so God intended for the rabbis to wrestle to arrive at halakah. Halivni also brings into his discussion a version of progressive revelation---that God varies his revelation according to the time period.
Halivni's overall point may be that Jews should observe halakah, even if it does not accord with the Bible's plain sense, and even if halakah changes over time. So the halakah does not accord with some immutable will on God's part. What's important is the refining process of arriving at orderly, righteous rules for the community.
UPDATE: I read more of the book. Halivni referred to traditions saying that Ezra (through notation of the text and interpretation) corrected the errors of the Hebrew Bible that accumulated during Israel's pre-exilic period, when there was considerable neglect of the text, and Halivni holds that this was recovering the revelation from Sinai. The relevance of this point to peshat and derash appears to be that derash, when it contradicts the plain sense of the biblical text, may be recovering the original meaning of the passage, which became lost. Halivni also discusses rabbinic attempts to harmonize different scriptures by bringing in a third scripture, and this may relate to peshat and derash because such a harmonizing approach is not always faithful to the plain senses of the contradictory passages.
I am not sure if I understood everything in this book, but Halivni does cite a tradition that says that one can learn from study, even if one does not understand fully!