I think this has to do more with the governments than with any other factor. Governments are the ones that give them licenses and permits to operate in areas that are residential.
But why would someone even open a factory close to a residential house? It is common sense to know that factories should not be close to residential properties. I would sue such factory to court and get huge compensation pay.