Middle English smert described something that hurt. Smart later joined the vocabulary of wit and intelligence, and eventually described devices that seem to make intelligent choices. The familiar mental compliment has a much sharper physical ancestor.
Source
Etymonline: smartThe adjective history gives painful smert, personal intelligence with a qualified semantic explanation, and the later device use.