The exact origin of this phrase is unknown but it starts appearing in literary works as early as 1483 when Geoffrey Chaucer penned: "...a huge man, uncouth; a master of vessel and knew all the ports; not ride well; like a fish out of water as sat on his horse." The phrase meant then, as it still does today, that someone is in a situation that they are unsuited for or unfamiliar with. ( source )