Aerodynamics is a very intricate subject area, but I will do my best to present it in the simplest terms possible.
What you are probably already familiar with is the concepts of drag and downforce. Drag being bad, and down force generally being good. The best design possible will try to minimize drag and maximize the downforce. This being said, in many cases the amount of downforce you get is heavily dependent on the amount of drag a car sees.
The basic logic behind the whole ordeal of how drag and downforce come about are based on two main principles. Boundary layers and pressure differences.
The boundary layer concept stems from the idea that if you were to be on a surface with air flowing past it, the closer you get to the surface the slower the air will be moving past it. The air molecules at the surface can best be assumed as being stationary. But the farther away from the faster the air will be moving.
Generally, you want a nice smooth even boundary layer, if there is something that causes vortexes (little twirls of wind), then there will generally be an increase of drag. These vortexes form from a number of things. Things including surface roughness, sharp angles, the angle at which a slope diverges from an air way, and even the speed at which the surface is moving relative to the air.
To test and optimize a vehicle aerodynamically a couple main methods are used. The first is CFD (computational fluid dynamics) wherein you use a computer model of a vehicle and use programs to calculate how the air will flow around the various features. This is a very lengthy process and requires a lot of engineering know how and experience to optimize these models. But with enough computers/engineers you can rapidly develop a mathematically optimized car shape.
The second is by using a wind tunnel. This is perhaps the most accurate method to test, but is also perhaps the physically hardest to test as well. Not only do you have to manufacture all of the components for every little change you make, but you also have to create an ideal test chamber, hopefully with a treadmill floor to imitate road movement. In these tests Engineers generally use smoke trails and dip them around the various parts of the car looking for swirls of air, once found it's back to the drawing board to try and get rid of them.
Now onto downforce. Downforce is the byproduct of varying pressures around the vehicle. Every psi of pressure difference can make a huge impact on the overall downforce on the car. Especially when it is applied over very large surfaces.
A couple ways to influence the air to go into a high or low pressure zone are as follows.
To create a low pressure zone, the air needs to spread out. For example if you have a channel under the car that starts out small and spreads out into a wide free flowing tunnel, you will create a low pressure zone under the car when the air expands in your path. Say if you manage to lower the pressure by 1psi, and an air funnel has an approximate 3' by 8' surface area, the corresponding 3456 square inches of surface area will create 3456 pounds of downforce!
To create a high pressure zone, the air needs to be compressed. Air is compressed when the air flows over a spoiler, or over the windshield, or any other inclined or narrowing surface(s). A high pressure zone over the vehicle will again help force the vehicle down.
However to produce any large changes in pressure, there will also be increases in drag, this drag is created because it takes energy to compress and expand air from it's natural state. And as such will slow you down. The best you can hope for is to minimize the vortexes over these pressure inducing surfaces.
Now if you have a look at the car below, it shows an amazing example of doing everything possible to increase downforce. Take note of it's underbody. :) This car can pull over 4g's in a corner with all of the downforce it makes. In tests at 130mph in a wind tunnel it was putting 3x it's weight in downforce.