The doctrine of Middle Knowledge (MK) is today especially presented by philosopher William Lane Craig. Historically the MK position is attributed to the 16th-century Counter-Reformation theorist Luis de Molina. After him, the MK position is also called Molinism.
The basic problem MK addresses is: How could God know all things while at the same time persons make truly free choices? More than this, can God purpose and create things that must come to pass AND retain free will in persons so that persons are responsibloe for their choices? This is possible, say Molinists, if God has "middle knowledge."
What is MK? MK is this: God knows not only what "shall come to pass, he knows what would have come to pass if he had chose to create any other world - that is his "middle" knowledge" (from Divine Foreknowledge: Four Views, eds. James K. Beilby & Paul R. Eddy). As William Lane Craig writes, "By employing his counterfactual knowledge, God can plan a world down to its last detail and yet do so without annihilating creaturely freedom" (Ib., 122).
Now this sounds like a contradiction. Not so, say philosophical Molinists.
One key to understanding MK is to understand "counterfactuals of creaturely freedom" (CCFs). CCFs are "If... then..." statements. Such as: "If John (in certain specified circumstances) were faced with the choice between X and Y, John would choose (either X or Y)." This "If-then" statement is a "counterfactual." Because, if it is true that, given the specified circumstances, John choose X, then the statement "If John were faced with the choice between X and Y, John would choose Y" is counter to the fact that John would actually choose X.
Now the question is: Are there true counterfactuals? The Molinist assumes there are. Is this assumption logically contradictory? The Molinist shows how it is not. Therefore, it is logically possible that there are true counterfactuals. God, knowing all truth. therefore knows counterfactuals of creaturely freedom.
So, what's the point of all this? If there are true counterfactuals and God knows the truth of counterfactuals of creaturely freedom, then we have a logically possible situation where God foreknows all free choices humans will make. Thus divine foreknowledge is not incompatible with human freedom.
The logical implication of this is that because God has MK, God can create a world where His purposes can best be accomplished. In doing this God does not "force" persons to choose what He wants, thus persons have free will.
Finally, note this: the Molinist is not obligated to argue for the truth of MK. The Molinist is proposing a model where it makes logical sense to say both that God foreknows all human choices and humans make such choices freely.