I agree with you that it doesn't make sense to exclude someone for being a woman (or an Eskimo, handicapped, from Belgium or pretty much any other reason), if that person has the qualification you're looking for. In theory the companies that discriminate should suffer from a lack of talent or have to pay more for their workers, because they're recruiting from a smaller pool. I don't know if we want to wait for them to bleed to death, but eventually they will go away.
You're absolutely right that sexism doesn't make logical sense, I'm completely baffled when I hear stories about someone being rejected for being a woman. The sad part is that many of the women who step forward behave like self-entitled spoiled brats, so it becomes hard to tell if they where reject due to gender or personality.