There are worse things in the Wizarding Universe that ARE criminal. In particular - Mind Control.
Memory Charms seem only to wipe out an individuals recollection of events, meaning they can no longer remember certain things happening, but are still fully in control of themselves and, with time, could fully recover and become a functioning part of Wizard Society.
That being said, it's never stated that heavy-handed memory charms, like the ones Gilderoy Lockheart used, aren't illegal. All we know is that lower-level memory charms seem to be considered okay for keeping the wizarding world safe, and that Lockheart got away with his memory charms largely by nobody ever finding out he was doing it.
So in short, yes it probably should be illegal to wipe away someone's entire memory, and that is why the only person we ever see doing it is inequivocably a bad person. BUT, he doesn't get thrown in jail, probably because his memory of doing those things has been wiped clean, and so he isn't a danger to the wizarding society anymore.