How does that even work? Do they only eat the brains of Bad People?
I know that there's fluff that mindflayers prefer smart people, but do they have to eat sentient brains? Couldn't they just eat livestock brains to survive?
Depends on what fluff you're using. Lords of Madness specifies that the brains of sentient creatures with actual experiences are tastier and more nutritious to illithids than, say, brain-fried slaves or animals.
That doesn't even cover ceremorphosis, where the illithids insert a tadpole into a victim's head (via the mouth, nose, or ear canal). The tadpole crawls up into the person's brain and begins chowing down, destroying the victim's mind. Then the tadpole begins transforming the victim's body over the course of a week until presto, new illithid!
Illithids always use sentient creatures for ceremorphosis. Humans, elves (including drow), both flavors of gith (that must really piss the githyanki and githzerai off), grimlocks, gnolls, medium-sized goblinoids, and orcs are all ceremorphosis candidates. Other races are typically eaten or enslaved. The exception, of course, is the urophion, which is the illithid version of 'I got drunk last night and did what?' because it's the result of implanting a tadpole into a roper.
So yeah, illithids are bad news.