A spice may be available in several forms: fresh, whole dried, or pre-ground dried. Generally, spices are dried.
A whole dried spice has the longest shelf life, so it can be purchased and stored in larger amounts, making it cheaper on a per-serving basis. Some spices are not always available either fresh or whole, for example turmeric, and often must be purchased in ground form. Small seeds, such as fennel and mustard seeds, are often used both whole and in powder form.
The flavor of a spice is derived in part from compounds (volatile oils) that oxidize or evaporate when exposed to air.
Grinding a spice greatly increases its surface area and so increases the rates of oxidation and evaporation. Thus, flavor is maximized by storing a spice whole and grinding when needed.
The shelf life of a whole dry spice is roughly two years; of a ground spice roughly six months.
The "flavor life" of a ground spice can be much shorter. Ground spices are better stored away from light.