This has been used since the 15th century to mean maddened/out of one's senses. A similar phrase in French: 'hors de soi' - literally 'out of oneself' - means just the same thing. The idea is that you and your mind are somehow 'adrift' from each other, as it were.
Just to add an afterthought to my previous answer...the earliest-recorded version of the phrase in written English was in a Caxton publication of 1490 called 'Enydos'. In a sense, therefore, that's where it 'came from', though it may have existed before that in spoken form, of course.