Niccolò Machiavelli said this quote

..it happens in all human affairs that we never seek to escape one mischief without falling into another. Prudence therefore consists in knowing how to distinguish degrees of disadvantage, and in accepting a less evil as a good.