This character 乖 is used in words like 乖離, 乖違, and 乖戾, and means something along the lines of “to deviate from the norm or reason” or even “to disobey”. I’m wondering how it came to be used for a quite opposite sense as an adjective in reference to a child.
According to Wiki, 乖 does mainly mean "break away from the norm" and only meant "well behave" in slang.
乖 meaning obedient may have come from 乖巧
乖 (unusually) was used as an adverb to describe the degree of pleasing here
乖巧 --> 乖 - an obedient child is unusual (unusually pleasing)
It is like English using "sick" for "great" e.g "he has the sick skill" = "he has a skill so great that's to the point of abnormal (sick)
Another example is 贼 in slang usage
贼 (immoral) --> abnormal --> greatly/ extremely e.g. 贼好吃 (extremely delicious - it is a crime to be so delicious )
乖 (会意。小篆字形，象羊角形，从“北”。从“北”，取其分背的意思。本义:背离，违背，不和谐) has the following meanings: