Facebook Inc. said it is providing $1 billion to help ease a shortage of affordable housing in Silicon Valley, the third tech giant this year to commit to addressing the issue as the industry seeks to soften the impact of its rapid growth.

The social network company estimates its initiative will produce up to 20,000 new housing units over the next decade, much of it aimed at teachers, police and other middle-class workers near its headquarters in Menlo Park, Calif.

This...