There is no specific law for or against it.
However, it is a bad idea to have them live inside the factory premises as it messes up attendance and time records.
It is better to have it outside, or to demarcate the residential area from the factory license.
The answer will depends on whether the person is staying alone or with family.