The individual butterfly that is eaten does not, of course, benefit directly from its toxicity, but other members of a victim’s species do benefit from its sacrifice.
Poisonous species are generally warningly colored, as is the orange and black monarch butterfly, and may present other warning signals that predators learn to associate with an unpleasant experience with a toxic insect.
Since birds and other predators rarely die from eating a toxic insect, the other members of a victim’s species benefit from the sacrifice of their relatives, because their potential predators have been taught not to attack them. Even the victim benefits indirectly, because many of its genes will survive in its relatives, thus increasing the victim’s “inclusive fitness.”
The idea of inclusive fitness can be understood if we think of an organism as a gene’s way of making and passing on copies of itself—an idea not unlike Samuel Butler’s aphorism that “a hen is only an egg’s way of making another egg.”