late Old English, "twisted, crooked, wry," from Old Norse rangr, earlier *vrangr "crooked, wry, wrong," from Proto-Germanic *wrang- (source also of Danish vrang "crooked, wrong," Middle Dutch wranc, Dutch wrang "sour, bitter," literally "that which distorts the mouth"), from *wrengh-, nasalized variant of *wergh- "to turn," from PIE root *wer- (2) "to turn, bend."
Sense of "not right, bad, immoral, unjust" developed by c. 1300. Wrong thus is etymologically a negative of right (adj.1), which is from Latin rectus, literally "straight." Latin pravus was literally "crooked," but most commonly "wrong, bad;" and other words for "crooked" also have meant "wrong" in Italian and Slavic. Compare French tort "wrong, injustice," from Latin tortus "twisted."
As an adverb from c. 1200. Wrong-headed is recorded by 1732. To get up on the wrong side (of the bed) "be in a bad mood" is recorded from 1801, according to OED, from its supposed influence on one's temper; it appears in Halliwell's "Dictionary of Archaic and Provincial Words" in 1846, but doesn't seem to have been used much generally before late 1870s. To rise on the right side (of the bed) is proverbial by 1560s indicating either good luck or a good disposition. To be on the wrong side of a given age, "older than," is from 1660s. Wrong side of the road (that reserved for oncoming traffic) is by 1838. To be from (or on) the wrong side of the tracks "from the poor part of town" is from 1921, American English.
-ly 2
common adverbial suffix, forming from adjectives adverbs signifying "in a manner denoted by" the adjective, Middle English, from Old English -lice, from Proto-Germanic *-liko- (cognates: Old Frisian -like, Old Saxon -liko, Dutch -lijk, Old High German -licho, German -lich, Old Norse -liga, Gothic -leiko); see -ly (1). Cognate with lich, and identical with like (adj.).
Weekley notes as "curious" that Germanic uses a word essentially meaning "body" for the adverbial formation, while Romanic uses one meaning "mind" (as in French constamment from Latin constanti mente). The modern English form emerged in late Middle English, probably from influence of Old Norse -liga.