I'm not a vet or doctor or anything, but it looks like alien hand syndrome, which is not a mental illness, but a neurological one. To sum up quickly, those who suffer from this disease have one or more limbs, which they can not control properly, as in it usually moves without its host being aware of this activity. Sometimes it's something harmless, like wiggling or such, sometimes it's kinda makes sense but happens without the host's consent, like grabbing food without permission, and in some cases it can be violent and dangerous, even towards its host. Like I read about a guy, who sleeps with his hand restrained, cause on night he woke up because his own hand was choking him.
Yeah, unfortunately something is wrong with this dog's mind. Not going to argue they're as intelligent as humans, but they're pretty smart and they're certainly not retarded.