I don't think it's the legitimacy of the child that's in question, but whether or not there are parents and godparents who will be responsible for raising the child Catholic.
One illegitimate child may have a repentant mother who desires nothing but the best Catholic life for her child. Thus, no problem with obtaining a baptism.
In another instance, the parents, although claiming to be Catholic, might still be leading lives of sin and are clearly not living the Faith. It would be good to inquire of the mother why exactly she wants the child to be baptised. You'd perhaps find that it's for social reasons as it's simply what the extended family customarily does.
It's my understanding that baptising a child in a non-believing family does the child no favors as it "raises the stakes" on that child's soul in terms of the devil's desire to reclaim that individual. If the Church were to baptise children of obviously non-Catholic parents, why