Are mentally ill people allowed to perform research? Is it acceptable for a person to be a researcher if she/he has a mental disorders or illnesses?
Are there laws that either prohibit or not prohibit mentally ill to perform research? Caveats?
Let's turn this around and ask the converse.  How could you tell if a researcher has a mental illness or similar disorder?
Modern understanding of mental illness has moved towards a recognition that humans have an extremely wide range of functional cognitive and behavioral patterns. This means that most mental illness exists on a spectrum, where the boundary to illness is quite fuzzy, is only considered an illness if there is a persistent impact on a person's ability to function.
So if a researcher is producing work that is passing peer review in reasonable publication venues, then they are clearly functioning at a level sufficient to conduct scientific research, and that research is being found to be acceptable. That's it. There is no other scientific bar.
Some levels of mental illness will, of course, make it difficult or impossible for a researcher to produce acceptable research. For example, a person suffering from severe dementia would likely have a difficult time accomplishing any task in their life, including research. This isn't about saying it's not acceptable for any given person to conduct research, however, but rather that some illnesses will inhibit a person from actually accomplishing the task.
In certain niche cases requiring certification, significant impact from a mental illness on a person's trustworthiness may also preemptively bar a person from conducting research on subjects requiring that certification. For example, a person with schizophrenia not responding to treatment might not be able to work in a medical field requiring the handling of confidential patient information or at an organization that requires a security clearance.
In history, unfortunately, we find a very different situation. Until surprisingly recently, for example, homosexuality was considered a mental disorder, and many people were denied work on the basis of their sexual preferences.  I believe this remains the case in some repressive nations today.
Bottom line: in any modern liberal society, mental illness is no bar to research in and of itself, though it may become a barrier if it affects ones' ability to function as a researcher.