This picture shows some common tomato leaf shape mutants. Mutants (which generally are each broken at a single gene) are a really powerful tool for figuring out what individual genes actually do. In this case, they help us figure out how different plants are able to produce their extraordinary diversity of leaf shapes.
The top left image is a normal tomato leaf. Tomatoes have compound leaves with about 7 leaflets (which themselves can be further divided) with some little flat extensions of leaf tissue in between. Mutations in individual genes can force the leaf to bifurcate further or form one single, continuous blade.
Plant scientists have made some great progress figuring out how plants regulate leaf shape. Much of it is controlled by the plant hormone auxin. Scientists have found that if they add microscopic drops of pure auxin to baby leaves as they're developing, additionally leaflets will form at each drop. Additionally if they leave a long line of auxin, a flat leaf blade will emerge along the entire line. In normal plants, these spots form on their own as the leaf grows (and additional spots form in between as they're stretched apart). This way, tomatoes can form leaves with a consistent shape whether they're baby 3-leaflet leaves or large 9-leaflet ones.
This suggests that compound leaf development requires isolated spots of auxin. Accordingly, genes have been discovered that are either required to initiate these spots or to inhibit auxin in between the spots. Using genetic engineering techniques to increase or decrease the expression of these genes has predictable results and can produce non-compound leaves that are completely surrounded by a continuous blade, or that lack blades completely (and look like cactus spines!).
Both tomato and its sister species, eggplant, have relatives with leaves that have different levels of complexity. Different versions (alleles) of these genes have been found in these species. Ultimately these genes are translated into proteins, which react with other proteins and DNA to control leaf morphology. Some of these proteins have been found to vary in their binding affinity among species - e.g. a protein that positively regulates large numbers of leaflets is "stickier" in a complex-leafed species, interacting more with its partners and making a stronger "make leaflets!" signal.
So why do plants go through so much trouble to create such a variety of leaf shapes? This is still an open question, but leaves of different dimensions, with different degrees of division, lobey-ness and serration likely differ in temperature conduction, gas exchange, water relations, herbivory, disease susceptibility and light interception.
I love this black and white picture,* which illustrates how leaves vary with the environment. The big leaf on the left is a red maple grown in Vermont. The tiny leaf on the right is the same species, but grown in Florida! The color picture is my conception of what a "red maple" looks like - and reflects that my youth was spent in between these two latitudes!
*Royer at al. 2008. New Phytologist. 179: p.808-817.