This leaves a sort of empty space without as much air. The empty space is like a vacuum, and it sucks the airplane upwards. The wing slice in this picture isn't very good. You could make a wind- tunnel and try a couple thousand different shapes and pick the best one. Most people designing wing shapes use math, like the Bernouli principle.
Different shapes are good for different things, like going fast or slow.
When the airplane is not going so fast they stick these parts out to make the wing bigger. If your math is good enough maybe you can design your wing just right the first time without running thousands of windtunnel tests.