In the case of Nix v. Hedden, the U.S. Supreme Court ruled that tomatoes are vegetables, despite the botanical fact that tomatoes are fruits. According to the Concise Oxford Dictionary of Botany, a fruit is defined as "strictly, the ripened ovary of a plant and its contents. More loosely, the term is extended to the ripened ovary and seeds together with any structure with which they are combined."
To illustrate this definition, let's focus on a fruit more commonly recognized as such: the apple. Botanists consider an apple core a fruit, because it is a ripened ovary containing seeds. But by the looser definition of fruit, an entire apple (the core and the flesh surrounding the core) is also considered a fruit. Common garden "vegetables" that are actually fruit, include cucumbers, squash, peppers, and yes, tomatoes. Vegetables encompass all other edible parts of a plant that aren't fruit, including roots, tubers, stems, and leaves. Potatoes, carrots, greens, fennel bulbs, and onions are examples of real vegetables.
So why was it so important that tomatoes be defined legally as a vegetable? Well, back in 1883, a tariff was put in place to protect domestic vegetable growers by taxing imported vegetables. In 1886, the plaintiffs (Nix) imported some tomatoes from the West Indies. The collector of the port of New York (Hedden) imposed a duty on the tomatoes, which he considered vegetables. The plaintiffs paid the duty under protest and sued Hedden, arguing that tomatoes are botanically a fruit, and therefore should not be taxed as a vegetable. The case eventually ended up in the Supreme Court, which decided that while tomatoes are indeed botanically defined as fruit, consumers think of tomatoes as vegetables, and that is how they should be legally defined.