If you cook someone's goose, you spoil their chances, ruin their plans, put them at a disadvantage, or thwart their efforts.
Myth dictates that this saying came into being in medieval times, when inhabitants of a besieged town displayed a goose on the walls as a sign of contempt for their attackers. It is not known why a goose would be used in this manner.
At any rate, the village was apparently defeated and the goose cooked in triumph.
A more detailed version of this supposed origin suggests that it was King Eric of Sweden who experienced the incident. He approached a little-defended town, which mocked him with a goose upon their walls. (Again, it is not clear why the goose.) When the town discovered that they were likely to be defeated, they reversed their attitude and sent messengers asking what the King wanted from them. His reply might have been "To cook your goose for you!"
Another suggestion is that the phrase comes from the Aesop fable about the goose that laid golden eggs (sometimes a hen); the impatient and greedy owner of the goose cuts open the goose and finds nothing, ruining the source of the golden eggs and cooking his own goose, so to speak.
However, all of these theories are pure guesses. The first two are extremely vague in regards to location and date, making them rather dubious. The third is quite possible, but if it were the origin the phrase would likely be older.
"To cook someone's goose" was not on record in writing before 1851, when it made an appearance in the OED. A variant, "to do someone's goose", appeared only two years before, in 1849, when it was mentioned as "a vulgar phrase".
Where did "to cook someone's goose" come from? One of life's unanswerable questions.
Devious Derivations by Hugh Rawson (Castle Books, 2002)
The Wordsworth Dictionary of Idioms (1993)
The Bedtime Browser at http://www.briggs13.fsnet.co.uk/book/g.htm