The following is taken from The Phrase Finder (http://www.phrases.org.uk/meanings/by-hook-or-by-crook.html).
By whatever means necessary - be they fair or foul.
It is sometimes suggested that 'by hook or by crook' derives from the custom in mediaeval England of allowing peasants to take from royal forests whatever deadwood they could pull down with a shepherd's crook or cut with a reaper's billhook. This feudal custom was recorded in the 1820s by the English rural campaigner William Cobbett, although the custom itself long predates that reference. Another commonly repeated suggestion is that the phrase comes from the names of the villages of Hook Head and the nearby Crooke, in Waterford, Ireland. Hook Head and Crooke are on opposite sides of the Waterford channel and Cromwell (born 1599 - died 1658) is reputed to have said that Waterford would fall 'by Hook or by Crooke', i.e. by a landing of his army at one of those two places. A third suggestion is that the phrase derives from two learned judges, called Hooke and Crooke, who officiated during the reign of Charles I (born 1600 - died 1649) and who were called on to solve difficult legal cases. Hence, the cases would be resolved 'by Hooke or by Crooke'.
Only the first of the above suggestions stands up to scrutiny by virtue of the age of the phrase. The earliest references to hooks and crooks in this context date back to the 14th century - the first known being from John Gower's Confessio Amantis, 1390:
What with hepe [hook] and what with croke [crook] they [by false Witness and Perjury] make her maister ofte winne.
Gower didn't use the modern 'by hook or by crook' version of the phrase, but it is clear that he was using the reference to hooks and crooks in the same sense that we do now.
The earliest citation of the phrase that I can find is in Philip Stubbes' The Anatomie of Abuses, 1583:
Either by hooke or crooke, by night or day.
There are several other theories as to the origin of 'by hook or by crook', all of which are either implausible or arose too late. Taking away those, we are left with two serious contenders: sheep farming and wood gathering.