Early in our cooking-baking life, we learned firsthand the enormous difference between making chocolate chip cookies with butter that is essentially melted, with room-temperature butter, and with butter at refrigerator temperature. The temperature of the ingredients has a lot to do with how the cookies turn out.
If you put a warm, melty dough into the oven, your cookies will spread before they begin to set up. Too often they'll run into one another, becoming a single crisp, crunchy mess on your cookie sheet. The cooler the dough when it goes into the oven, the less it will spread.
Another reason that cookie dough is refrigerated is that it gives the gluten time to relax. You don't want to mix a cookie dough containing wheat flour any more than absolutely necessary, as the more you mix it, the more gluten develops, and the more rubbery your cookies will be. Letting the dough rest in the refrigerator for at least half an hour does wonders for relaxing the gluten and letting you produce cookies that are soft or crunchy (depending on your preference), but not tough and rubbery.
Finally, letting the dough rest in the refrigerator also gives the flour more time to absorb the liquid more fully. This allows the dough to become drier and firmer, which produces a better consistency in the finished cookie and also better taste. Even Ruth Wakefield, creator of the Toll House Chocolate Chip Cookie, said she chilled the dough overnight.
A writer for The New York Times recently conducted an experiment with a batch of chocolate chip cookie dough, where he baked a portion after chilling the dough for 12 hours, for 24 hours, and for 36 hours. The 12-hour cookies were fine; at 24 hours "things started getting interesting," with more even browning and better flavor; at 36 hours, the cookies browned still more evenly, and had "an even richer, more sophisticated taste, with stronger toffee hints and a definite brown sugar presence." In an informal taste test among his colleagues, the 36-hour cookies won conclusively.
We have been speaking mostly of chocolate chip cookies – the dough of which we generally can't muster the fortitude to store in the refrigerator for even a few hours – but the rules can be applied to nearly any cookie.