If a particular gene causes good things 95% of the time (based on other interactions or developmental factors or whatever) and catastrophic failures like heart disease or cancer or crippling depression 5% of the time (and it represents a local maxima, with no simple improvements possible), then it can easily come to dominate a gene-pool, so long as the 95%-benefit outweighs the 5%-failure. It doesn't mean the 5% failure has been "selected for", it just means that it wasn't worth weeding out.
Moths circle lights because of genetic factors which influence their tiny moth brain's development. It doesn't mean that circling-lights was a selected feature.