So why are the wings on aircraft and racing cars broken up into multiple elements, with slots in-between? Well, it was found reasonably early in the history of aerodynamics that this technique enabled the total wing to continue generating lift at an angle of attack at which it would have stalled, were it to have been fashioned as a single element. The lift/downforce generated by a wing increases as the angle of attack increases, hence multiple element wings are a means of increasing peak lift/downforce. (In the case of aircraft, they are also a means of maintaining lift at the lower airspeeds associated with landing and taking-off).
But how does the introduction of slots achieve this effect? Well, A.M.O. Smith identified five distinct mechanisms in his 1974 paper, High-Lift Aerodynamics: slat effect, circulation effect, dumping effect, off-surface pressure recovery, and fresh-boundary layer effect.
So let's have a go at attempting to understand what these effects are. To start off, however, we need to recall some of the fundamental facts about how a wing works.
A wing generates lift/downforce because it generates a circulatory component to the airflow. The circulation only exists because of a thin layer of airflow adjacent to the wing called the boundary layer. Viscous effects operate in the boundary layer, but outside the boundary layer the airflow can be idealised as being inviscid.
When people speak of the velocity and pressure of the airflow above and below a wing, they are implicitly speaking of the velocity and pressure on the dividing line which separates the boundary layer from the inviscid airflow. Here, Bernoulli's law applies: if the airflow is accelerated, the pressure decreases, whilst if the airflow decelerates, the pressure increases.
The low pressure surface of a wing initially accelerates the airflow, and then decelerates it towards the trailing edge. Hence, there is higher pressure at the trailing edge than at the point of maximum velocity, and this corresponds to an adverse pressure gradient along the latter part of the boundary layer.
The circulation around a wing is crucially dependent upon the boundary layer remaining attached to the surface of the wing. If the adverse pressure gradient is too steep, reverse flow ensues, the boundary layer detaches, and the wing stalls. This will happen as one attempts to increase the amount of lift/downforce by increasing the angle of attack.
Ok, so that's some of the fundamentals of wing aerodynamics. Now, if the boundary later detaches when the adverse pressure gradient becomes too steep, it follows that reducing the severity of the adverse pressure gradient at a fixed angle of attack will keep the boundary layer attached. And this is exactly what a multi-element wing does.
Imagine for a moment a three-element racecar wing. The small leading element is called a slat, and the element behind the main plane is called the flap. Imagine the airflow coming from left to right. There will be an anti-clockwise circulatory component to the airflow around each element. One effect of this will be to reduce the acceleration of the airflow at the leading edge of the main element, and to thereby reduce the low pressure peak at that point. In simplistic terms, the circulatory component to the flow at the trailing edge of the slat is in an opposite direction to that at the leading edge of the main plane, hence the slot gap reduces the velocity of the airflow here. By reducing the low pressure peak at the leading edge of the main plane, the adverse pressure gradient along the main plane will be reduced, thereby helping the main plane to hang onto its boundary layer. This is the slat effect.
Meanwhile, the flap will have its own circulation, and as a consequence, at the point where the trailing edge of the main plane discharges its boundary layer, the airflow velocity will be greater than it would in the absence of a flap. Thus, the high pressure at the trailing edge of the main plane is reduced, once again reducing the adverse pressure gradient along the main plane, helping to keep the boundary layer attached. This is the dumping effect.
Now, according to Smith, the circulation of the flap enhances the circulation of the main plane, and in the presence of a slat, the circulation of the main plane enhances the circulation of the slat. As yet I can't intuitively see why this is the case. Smith claims, however, that this circulation effect is closely related to the dumping effect, and asserts that the downstream element induces cross-flow on the trailing edge of the upstream element, which enhances its circulation.
The off-surface pressure recovery effect, meanwhile, is a consequence of the dumping effect. A downstream element reduces the deceleration towards the trailing edge of an upstream element, keeping the boundary layer attached, and releasing the boundary layer from the trailing edge of the surface, where it completes its deceleration in a manner which doesn't cause reverse flow. The boundary layer of the main plane, for example, will discharge into the region outside the boundary layer of the flap, and continue to decelerate until it reaches the trailing edge of the entire wing system, (see the diagram here from Zhang and Zerihan, Aerodynamics of a double-element wing in ground effect, 2003).
The final effect, the fresh boundary layer effect, means that each element acquires its very own boundary layer, fed by the freestream velocity. This keeps the boundary layer of each element thinner than the boundary layer on a single wing of the same length, and thinner boundary layers are able to withstand greater adverse pressure gradients.
So it's all about increasing circulation and mitigating the causes and effects of adverse pressure gradients.
Note, of course, that the function of a DRS rear-wing in modern Formula 1 is dependent upon these aerodynamic effects. The rear wing is designed so that the main plane is at an angle of attack which would cause the boundary layer to detach in the absence of the flap. With the flap in place, the severity of the adverse pressure gradient is reduced by the acceleration of the airflow around the leading edge of the flap. Open the flap, and the main plane is suddenly dumping its boundary layer into freestream airflow, as a result of which the adverse pressure gradient steepens, and the boundary layer detaches, causing the main plane to stall.