The story
The adjective is derived from half- (prefix meaning ‘incomplete, partial’) or half (adverb) + baked (“cooked by baking; (slang) drunk”, adjective). The noun is derived from adjective sense 1.2 (“of a person: having no common sense or intelligence”).
Etymology from Wiktionary, CC BY-SA 4.0.