Meet the Mallows

Contrary to popular belief, cocoa isn't related to coffee, coconut, coca, or carob.

Cocoa, coffee, coconut, coca, and carob are all flowering plants (meaning that they all belong to the same kingdom and phylum) - but that's where the botanical relationship between them ends.
Some people think that cocoa and coffee are related, because both plants produce beans that taste bitter and go dark brown during roasting.
Some people think that cocoa, coconut, and coca are related because their names sound similar.
Some people think that cocoa and carob are related, because carob is often promoted as a chocolate substitute.
Although these similarities are undeniable, they do not prove a relationship any more than having blue eyes or a similar name proves a relationship between people (leaving aside the fact that all human beings are more closely related than cocoa and coffee, given that we all belong to the same species: Homo sapiens).
In fact, cocoa is more closely related to durian (the fruit that notoriously smells like a public toilet) than to any of the plants starting with "c" mentioned above.
We can quite easily look at a plant's well-documented family tree, or taxonomy, to understand the relationship it has with other plants.
The taxonomy most commonly applied to plants was devised by Swedish botanist Carl Linnaeus. Linnaeus was also the man who gave the cocoa tree its name: Theobroma cacao.
Linnaean taxonomy recognises seven hierarchical categories, listed below, with cocoa's "family tree" in the right-hand column.

Kingdom -- Plantae (plants)
Phylum -- Anthophyta (flowering plants)
Class -- Dicotyledon (dual seed leaf)
Order -- Malvales
Family -- Malvaceae (mallow family)
Genus -- Theobroma
species -- cacao

The further down the taxonomic hierarchy a relationship reaches, the more similar (or closely related) two plants are, until you arrive at the species, which identifies only one distinct plant, such as cacao. (To confuse matters a little, you can have distinct varieties within a species. For instance, cocoa is a single species - cacao - with three distinct varieties: criollo, trinitario, and forastero).
Linnaeus' classification system - Systema Naturae - was first published in 1735. Systema Naturae evolved considerably over the course of Linnaeus's life, and aspects of his taxonomic system are still subject to debate and change. For example, following molecular-level investigations, the family classification of cocoa has recently been changed from Sterculiaceae to Malvaceae [1].
Linnaeus made his classifications according to the number and arrangement of floral reproductive organs on a plant. However, this narrow focus often produced poor or unnatural groupings. Modern classifications take into account each plant's overall morphology (that is, the form and structure of its roots, leaves, flowers, seeds, fruit, and habit), as well as a plant's natural distribution (that is, where it grows).
Today, we still employ Linnaeus's simple and elegant system of naming plants using binomial nomenclature. Binomial nomenclature literally means a "two-name naming system" (the words binomial and nomenclature both stem from the Latin nomen, meaning name). Following this convention, every plant has a scientific Latin or botanical name that consists of both its Genus (always capitalised), followed by its species (always in lower case). Hence, the botanical name for cocoa is Theobroma cacao.
In the natural world, there are generally considered to be four or five kingdoms, although some modern classification systems recognise more than five. The five-kingdom classification encompasses: Plantae, Animalia, Fungi, Protista, and Monera (the kingdom of bacteria and blue-green algae).
All plants belong to Kingdom Plantae (the plant kingdom).
Within the plant kingdom, there are twelve phyla or divisions. The vast majority of plants produce flowers, which places them in the phylum Anthophyta. (The non-flowering plants include ferns, mosses, and conifers).
Within the phylum Anthophyta (flowering plants), there are two classes: Monocotyledon (meaning single seed leaf), and Dicotyledon (meaning dual seed leaf). Coconut and vanilla both belong to the class Monocotyledon. Cocoa, coffee, carob, and coca all belong to the class Dicotyledon - but this is where their relationship ends.
Within these classes, there are dozens of different orders. And within those orders, there are even more families. Looking at the examples below, you will notice that a naming convention exists for plant orders and families: a plant order ends with the letters ales, while a plant family ends with the letters aceae.

Table: See which plants cocoa is (and is not) related to ...

Order Family Genus / species common
used for ...

(Class: dicotyledon - dual seed leaf)
the mallows
Malvaceae Theobroma cacao cocoa seeds > chocolate
Cola nitida kola nut seeds > cola flavour
Durio zibethinus durian fruit > edible but smelly!
Ochroma pyramidale balsa wood timber > soft craft wood
Althaea officinalis marshmallow root > confectionery
the gentians
Rubiaceae Coffea arabica
Coffea robusta
coffee seeds > stimulant drink
Cinchona pubescens quinine tree bark > anti-malarial
Gardenia sp. gardenia flower > ornamental
the geraniums
Erythroxylum coca coca leaves > cocaine
Tropaeolaceae Tropaeolum majus nasturtium flower > edible
Geraniaceae Geranium sp. geranium plant > ornamental

(Class: monocotyledon - single seed leaf)
the palms
Arecaceae Cocos nucifera coconut palm fruit > edible
the orchids
Orchidaceae Vanilla planifolia vanilla seeds > spice


[1] The plant families Malvaceae, Sterculiaceae, Bombacaceae, and Tiliaceae were confirmed by molecular studies to be monophyletic. "Monophyletic" means a group of organisms that are believed to have originated from the same ancestor. Hence, these four families are known as the "core" Malvales.

The Cocoa Communiqué

An historical specimen of Theobroma cacao.
Image from the Swedish Museum of Natural History

Two Theobroma cacao pods: same species,
different varieties.
The forastero pod on the left is relatively spherical and smooth, while the trinitario pod on the right is elongated and ridged.

Carob - Ceratonia siliqua - belongs to the legume family. It is related to peanuts, green beans, and lentils - but not to cocoa!

Coffee is a member of the gentian order. It is related to the Gardenia - but not to cocoa!

Believe it or not, balsa wood and cocoa are related - they both belong to the mallow family!

Erythroxylum coca.
Some people believe that chocolate is addictive - but it's definitely not as addictive as cocaine, which is made from the coca leaf.
Cocoa and Coca are not related!