A recipe calls for me to sweat finely chopped onions. What do I do, and why?
First, finely chop the onions. This makes them smaller, faster-cooking, and less of a textural presence in the dish. Do it by cutting straight through the poles of the onion, resulting in two halves. Then chop off the knobs and peel off the outer layer. Run the knife 8 or 9 times along the vertical (from pole to pole), but don't sever one end completely. Cut finely across these verticals to make a fine dice. Run the knife over the pile a few times if your cut isn't small enough.
Second, cook the onions. The purpose of sweating is to draw moisture out, concentrating the flavor and enhancing conversion from starch to sugar. Heating the onions releases their aroma and reduces the chemical bitterness they exhibit when raw. Heat up some oil in a pan to medium-low heat. Add the onions. Add salt. I wouldn't cover the pan, since the lid will prevent steam from escaping. Stir/shake to prevent sticking or burning. The onions will get soft and then translucent. (Eventually, if you kept going they would get limp and browned; this is referred to as caramelized and considered a different thing than sweated, so although it's just further along the same spectrum, you shouldn't go that far for this recipe).
That's how I'd do it and why. I don't know if it's a textbook answer.
You need a pan with a tight lid, put it on the hob on a low heat with a small amount of oil. Add the onions to the oil, stir them round so that the onions are coated with oil, put the lid on and leave them for 5 minutes. Take the lid off, stir and put the lid back for another 5 minutes. Repeat this until the onions are soft and translucent but not browning.
Sweating is done with lid on pan. Not using a lid would be like using the sauna with the door open.
Sweating is the process of releasing flavors with moisture and low temperatures. Fat, in this case, is used just to hold the non-volatile flavors as they're released from the onion. No browning takes place. The pan is covered so the lid traps steam, which condenses and drips back on to the onions. Some cooks cover the onions directly with a piece of foil or parchment, than add a lid as well. The cooked onions have a more mellow favor with this technique as the more you cook an onion, the sweeter it gets. Sweating onions is especially desirable when making white sauces that contain onions, as no color is added to the sauce. Also used in make risottos.