They are self medicating because there is no proper treatment. We can roll the dice with treating mental illness, but it's not very consistent or reliable and often produces undesirable side effects. At least, that's what I've seen when family members have gone to psychiatrists to treat various things.
Well, there are many levels and types of mental illness and in some cases, people aren't even aware that they have it. What I know is that there is more that we can be doing today to help those who have mental illness, both in terms of diagnosing those who don't know they have it and treatment (both therapy and pharmacologic) for those that are diagnosed.