Our olfactory system has no magic ability to detect what is or isn't dangerous. That an unpleasant smell causes headache/nausea is one thing, the long-term health impact should be expected to be independent of this.
It absolutely does have a pretty magic ability to detect danger, that's sort of its purpose. As an example, last I checked, the human nose is the most sensitive device we have to detect spoilt milk.
Taste, smell, touch, all our senses are pretty damn good at parsing danger when functioning normally. Though I would bet with really un-natural substances the reliability goes down.
Yes, the human nose has evolved sensitivity to sulfide substances produced by bacteria that spoil food. For example, the humans can barely smell 0.001ppm of dimethyl sulfide (from decomposing vegetables) and 1ppm of formaldehyde [0]. Human noses are three orders of magnitude more sensitive to the relatively safe dimethyl sulfide than to the dangerous formaldehyde. Formaldehyde can harm you even when you can't smell it (at 0.1ppm [1]).