Drop a bit of detergent, and chances are it'll dry with all the particles spread evenly throughout the area that was once a puddle. The same with a muddy pool — when it dries, you don't see the bits of mud all swept to the outer lip. But when you dissolve coffee grounds in water, then spill the suspension, a very physical rearrangement happens: the grounds go from being evenly dispersed throughout the liquid, to being clumped crustily on the edges when it dries. Scientists call this the “coffee ring effect” (though full disclosure, coffee isn't actually the only liquid to do the ring thing — you’ll know from evening cocktails that red wine will do the same to your linoleum).
How it works:
[T]he shape of the drop is like an over-turned bowl, fat in the center, sloping down to the edges. And because the edges are less packed with water molecules, the water out there evaporates more quickly. But here's the thing: when the drop hits a surface (whether it's a countertop or a page of your journal), that surface catches the rim of the droplet in a wrestler-like grasp — the rim gets PINNED to the surface, and can't move. Ever. So as the water evaporates, escaping as a gas, the pinned drop can't shrink into itself. Instead, it flattens out — keeping a constant width as it pushes water from the center out toward the stuck rim. And as the water is pushed toward the rim, it carries with it all those dissolved particles (coffee grinds!) … which stay behind after the water evaporates. Voila! A ring is formed.
(Hat tip: Dan Colman)