Crime is not always linked to mental illness. Many crimes are committed precisely because, their circumstances being what they are, the sane course of action is to violate the law. If you are legally required to pay $50000 in taxes, but you don’t, since you know you won’t get in trouble, you are committing a crime but are acting rationally.
There are some laws that, under certain circumstances, are hard to violate without getting in trouble; and those who do violate are obviously disproportionately likely to be mentally ill. But that is pretty much the beginning and end of the connection between criminality and mental illness.