The phrase ‘never buy a pig in a poke’ is linked to another phrase ‘he let the cat out of the bag’ which means to give away a secret. A ‘poke’ was a name for a bag or sack in the 18th century.
This phrase concerning cats comes from the time when piglets were taken to market in a sack to be sold. A fraudster would place a cat inside the bag pretending it was a piglet. When the buyer wanted to see the pig he was told that it too active and might escape. But if the cat struggled too much to get out and forced the fraudster to release the cat his secret was exposed; hence he let the cat out of the bag.
There we have it: two old-fashioned English sayings linked by a trickster’s shenanigans and country life.
P.S. ‘Poke’ has its origin in the French ‘pique’. The word ‘poke’ is still used in some places.
Sources: PoC, Desmond Morris, Google search results (reading direct from the results) and Brain Worm Farm (picture).