There are a number of good reasons why the ballast layer needs to be free draining. The main objective of the ballast layer being free draining is somewhat tautologically to keep the water out of the track structure.
Why is this necessary? Well, there are are two main underlying reasons why you don't want water in your track structure:
It tends to lead to deterioration in the track geometry through various mechanisms, which leads to lower speeds, increased derailment risk and more expensive track resurfacing.
It tends to lead to deterioration of your ties (concrete, timber and steel alike), which means you have to replace them more often.
There are a few key mechanisms that cause the deterioration in track geometry:
When the water stops moving through the ballast it stops washing out contamination of fines (through local sedimentation or from the breakdown of the ballast itself). The standing water then tends to bind with the fines to create a mud slurry which both erodes the ties and quickly rounds the ballast rocks.
This is bad because ballast rocks rely on their irregular shape to provide a solid and stable layer; when new, the ballast rocks can interlock with one another and quickly reach a relatively stable lowest energy state with high strength characteristics. As the rocks become rounded and smaller they settle further and interlock less well, reducing the overall strength of the layer.
The pumping action of trains passing over the ballast layer when it is wet tends to drive water into cracks in the subballast, which can drive the water down into the track foundation. Either way, both the subballast and the foundation will tend to be weaker when wet, and the action of the water infiltration will also erode these layers, which only makes the problem worse.
In soils with a high expansiveness (in particular clay), they may vary volumetrically quite substantially when they are wet as opposed to being dry. So, when the formerly dry formation gets wet, it can heave, and then when it dries out, it shrinks again. These processes are not uniform and so lead to poor top geometry.
Similarly, in areas where freezing temperatures are encountered the water in the soil can freeze; ice has a lower density than liquid water and so you get heave, and then shrinking again when it melts. Melt water is also a great eroder.
For all of these reasons we like to keep water from entering the formation (so far as is reasonably possible) and drain it out quickly when it does get in there.
I'm afraid I don't know very much about slab track but I suspect that as you speculate, it is relatively impermeable to water and also not especially susceptible to erosion, and so the formation stays dry even if the slab track above it is practically under water.