According to Webster, “smart” derives from Middle English smerten, which in turn came from Old English *smeortan * and is akin to Old High German *smerzan * (to pain). I guess the question should be: how did this word come to mean “intelligent?”
I read an article (I think it was by Richard Lederer) that pointed out the curious fact that many words in English that are synonyms of “intelligent” are metaphorically linked to either light or cutlery.
clever (related to “cleaver”)
Until some other logophile comes along with a better explanation, I would chalk up the word “smart” as just another follower of this trend. As to which category it belongs to, I’d say either one. Both bright light and cutlery are capable of causing pain.