>>121901868The Joker being mentally ill and in a psychiatric hospital was Denny O'Neill's idea. Through the Golden and Silver Ages he was scrupulously sane, if eccentric, and when he wanted to go to an asylum to work a scheme out he had to feign dementia, which worked too well for a while but he explicitly bounced back from it by story's end.
All the same, it makes more sense to portray him as mentally unwell. By the point he's reached now, he goes to such lenghts even when it's actively harmful and risky to him, that it's a definitely insane lifestyle.
Penguin is as sane as they come, Riddler just happens to have a powerful compulsion, Scarecrow is simply a sadist, but Joker goes too far in his pursuit of chaos for the mere sake of chaos, even when he's gaining no logical benefit from it.