How does the slotted flap work?
The slot helps to prevent early separation, so the flap stays effective for larger deflection angles. What that means in reality can be read in this old NACA report which compares two NACA23012 sections, one with a plain flap and the other with a slotted flap. I have copied the pressure distributions below from that PDF:



Now I need to explain a little how to read the pressure distribution plots. The solid line shows the local pressure on the upper surface while the dashed line shows the pressure on the lower surface of the airfoil. The X-axis runs along the chord. The Y-axis represents pressure (suction is up) and y=0 represents ambient pressure. The area between the dashed and the solid lines is proportional to the lift coefficient, which is helpfully shown below each plot.

Now to the curvature: As long as the lines show a gradient, flow is attached. Separated flow can be recognized by a horizontal line slightly above the X-axis. As you can see, we have already fully separated flow on the upper plain flap surface at 30° flap angle and 8° angle of attack. At the same angles the slotted flap still shows fully attached flow on both surfaces. Attached flow creates a suction peak at the nose of the flap, which in turn allows a higher suction value at the end of the fixed part of the airfoil. This in turn allows a much higher suction peak at the nose of the airfoil, so that the suction force over the whole chord of the airfoil with the slotted flap is much higher than on the airfoil with the plain flap.

Only at 50° flap deflection will the slotted flap also show flow separation over the rear part of the flap, but there is still a suction peak which helps to stabilize the flow over the fixed part and increases lift. Unfortunately, the plain flap was not measured at the same angle, but from the small change between the 30° and 45° flap angles you can see already that moving the flap to 50° will change little.

The reason for this difference is simple: While the plain flap has only the old, thick and tired boundary layer coming from the fixed part of the airfoil to work with, the slot allows the slotted flap to create a new, thin and vigorous boundary layer which can tolerate much higher pressure gradients. Another benefit is the unchanging direction of the local flow behind the fixed airfoil: This allows to use a thin, highly cambered flap airfoil which maximizes lift production. The old NACA airfoil did not take advantage of this, but modern airliner flaps certainly do.