Feces has a lot of fats, fibers, proteins etc. in them. To humans they're waste but many other things can make use of it. Flies don't eat the poop but they try to lay hundreds of eggs on to them, so when their larvae grow they have more than enough to grow big and strong ;)
Biological -- there are many species of flies, and many of them specialise in the food of their larvae (maggots). A relatively small number of species feed on feces, which are actually quite nutritional for a whole range of organisms. As they may require fresh poop for breeding, they naturally have a very good sense to smell that -- it must really smell yummy to them! :-)
Flies are among the first organisms in a chain of decomposers of organic waste materials, next to some species of beetles. Their larvae chiefly feed on the soft and moist material. Next will be fungi, other flies and beetles, mites (probably feeding on the fungi), springtails, isopods, nematodes, etc., all turning your compost into fertilised soil.
Source: biologist, been closely watching my compost toilet (not a sophisticated type where one would go for minimal fly attraction but made for fast fertiliser production).
Metaphorical -- well, in a world where greed is acceptable and exploitation is a norm, bad things attract bad actors (who may also be specialised to metaphorically feed on certain bad stuff) -- who will profit from such bad things.