Old English wis, from Proto-Germanic *wisaz (cf. Old Saxon, Old Frisian wis, Old Norse viss, Dutch wijs, German weise "wise"), from past participle adjective *wittos of PIE root *weid- "to see," hence "to know" (see vision). Slang meaning "aware, cunning" first attested 1896. Related to the source of Old English witan "to know, wit."
Wise guy is attested from 1896, American English. Wisenheimer, with mock German or Yiddish surname suffix, first recorded 1904.