As a user of Facebook, this method of discrimination is markedly different than physically showing up to a house for rent and the home owner taking one look at you, scrunching up their face, and saying it's no longer available, tipping you off that what they are doing is illegal.
In the context of housing ads (or employment) these tools DO NOT have legal uses.
Thus they are illegal.
Targeting specific demographic using protected categories in other areas can be legal too.
As a pharmaceutical company you can target women, men, seniors for targeted medications. As a LGBTQ dating site you can target based on sexual orientation and cis/trans. It is not illegal. Housing and jobs (maybe something else) are covered by specific legislation.
The fact an LGBT dating site can choose ‘don’t show to heterosexual people (a waste of my ad spend)’ is one of the reasons their platform is so effective, especially compared to mass media like TV/magazines.
The analogous argument for knives would be "In the context of torture knives don't have any legal uses. (So knife sellers need to put safe guards in preventing their knives from torturing people)".
I'm trying not to say anything too mean, so I'll just say this: learn some history.