Derived from sailing ships. The 'sheet' in the phrase uses the nautical meaning of a rope that controls the trim of sail. If a sheet is loose, the sail flaps and doesn't provide control for the ship. Having several sheets loose ("to the wind") could cause the ship to rock about drunkenly.
English Wiktionary. Available under CC-BY-SA license.