Foul is a nautical term meaning to entangle or entwine, and more generally that something is wrong or difficult. The term dates back to usage with wind-driven sailing ships.