Upset; with the top where the bottom should be.
'Topsy-turvy', as with similar phrases like 'upside-down' and 'arse over tit', refers to the top and bottom being interchanged from their usual places. They at least make more sense than 'head over heels', which appears similar also, until remembering that our heads are usually over our heels. 'Topsy' is clearly an allusion to 'top'. 'Turvy' isn't so easy to interpret. The numerous variant spellings in early citations, which include tervy, tirvy, turvy, turvie etc., don't offer much in the way of a clue as to the meaning of the word. It may be an adaptation of the mediaeval verb 'tirve', meaning 'to turn or to topple over'. It has also been suggested that 'turvy' is an allusion to 'turf' and that 'topsy-turvy' means 'with one's head on the turf'. That's possible, but none of the early citations of the phrase make any such allusion.
The term has been recorded since at least the 16th century, for example, this piece from Richard Eden's The decades of the newe worlde, 1555:
"They say that... they see the houses turne topsy turuye, and men to walke with theyr heeles vpwarde."