Onions are the poster child for the group of vegetables called alliums which includes garlic, leek, shallots, and chives. The distinctive flavor of alliums is due to sulfur compounds that work as irritants resulting in the spiciness of alliums. When cells are damaged by cutting or chewing, enzymes are released that breakdown sulfur compounds into smaller volatile compounds that give the raw allium flavor. Cooking causes these compounds to react with each other creating a range of different flavor molecules creating a depth of flavor. This complexity is why we love alliums so much that they are ubiquitous across dishes and cuisines.