Why shouldn't dogs eat chocolate?
The reason is simple: Chocolate contains cocoa which contains Theobromine. The darker the chocolate is (meaning the more cocoa it contains) the more theobromine it contains. This is a bitter alkaloid which is toxic to dogs (and also cats), but can be tolerated by humans.

The reason for this is the much slower metabolization of theobromine in the animals (there are reports for poisonings of dogs, cats, birds, rabbits and even bear cubs) so that the toxic effect can happen. Depending on the size of the dog, something between 50 and 400g of milk chocolate can be fatal. As mentioned by @anongoodnurse the cocoa content in milk chocolate is the lowest and much higher the darker the chocolate gets.

The poisoning comes from the Theobromine itself, which has different mechanisms of action:

First it is an unselective antagonist of the adenosine receptor, which is a subclass of G-protein coupled receptors on the cell surface which usually bind adenosine as a ligand. This influences cellular signalling.

Then it is a competitive nonselective phosphodiesterase inhibitor, which prevents the breakdown of cyclic AMP in the cell. cAMP is an important second messenger in the cell playing an important role in the mediation of signals from the outside of the cells via receptors to a reaction of a cell to changing conditions. The levels of cAMP are tightly controlled and the half-life of the molecule is generally short. Elevated levels lead to an activation of the protein kinase A , an inhibition TNF-alpha and leukotriene synthesis and reduces inflammation and innate immunity. For references see here.

The LD50 for theobromine is very different among species (table from here), with LD50 as the lethal dose killing 50% of the individuals and TDlo the lowest published toxic dose:



The LD50 also differs between different breeds of dogs, so there are online calculators available to make an estimation, if there is a problem or not. You can find them for example here and here. The selective toxicity makes it even an interesting poison for pest control of coyotes, see reference 4 for some details.

References:


Chocolate - Veterinary Manual
Chocolate intoxication
The Poisonous Chemistry of Chocolate
Evaluation of cocoa- and coffee-derived methylxanthines as toxicants
for the control of pest coyotes.