Demeanor means conduct, so a misdemeanor is literally bad conduct. It comes from the verb to demean, meaning to conduct, to transact business and to behave oneself. Both senses of demean date to the 14th century.
The current sense of demean is to put down, shame, debase, which looks like it might be from the 17th century. “to conduct” dates from the 13th (according to Collins). The current meaning seems to derive from “debase.”
C17: see de-, mean2; on the model of debase
I can’t get to OED on this.