That's mostly orthogonal to the H1-B question - why do they hire anyone? (Most of the hires are not H1-Bs.)
I'd guess the answer is, marginally, hiring people is still good for companies. But combined with the lack of housing development, it's slowly but steadily making life worse for everyone in the Bay Area who doesn't yet own a house.
If it continues this way, eventually people won't move here without ridiculously high salary offers, and companies will be forced to expand in cheaper cities instead.