Brewer's Dictionary of Phrase and Fable says that the phrase goes back to the Greek gnomic poets. The Oxford Dictionary of Proverbs attributes the similar phrase 'Whom the gods love die young' to Menander, a Greek comic playwright who flourished at the end of the 4th century BC/BCE.
The idea behind the saying seems to be that the world is a wicked place in which only evildoers can expect to thrive and survive. Those who have no talent for evil will die young, killed off by the wicked.