We have two words that sound the same: “wrack” and “rack,” and people often don’t know which one to use. Do you wrack your brain or rack your brain, for example?
Rack Your Brain
Despite sounding the same, the words actually have different origins. We have racks for storing spices and drying clothes, but in the Middle Ages, the rack was an instrument for torture. This R-A-C-K spelling comes from a word that meant “to stretch.”
You stretch people on a rack (or at least the torturers did), you stretch out your clothes to dry, and I suppose if you want to stretch the metaphor, you stretch out spices on a rack so you can see all those tiny bottles at once instead of having to get a step ladder like I do to rifle through them in my cupboard.
The “mental torment” meaning of “rack” in “rack your brain” and “nerve-racking” comes from the idea of the physical torment of stretching bodies on the rack. Those are both spelled R-A-C-K.