The principle of the lesser of two evils is derived from Homer’s Odyssey. In the story Odysseus must sail through the Straits of Messina to get home. On either side of the straight are two monsters, Scylla, a six headed monster who chucks rocks at boats and Charybdis, a giant whirlpool.
Odysseus decides to sail past Scylla, losing six of his crew but avoiding Charybdis, who would have sucked down the ship killing everyone. The point is that Odysseus has to sail though the straight and therefore has to decide which of the two evils will cause the least harm.