Bottom note box.
Phrases and Idioms - Meanings and Origins of Phrases | If you're interested in dog, cat and animal phrases in general, then check out that list!
Being in a difficult predicament; a mess; an undesirable situation.
This phrase goes back to at least the 1600s. It was utilized in a play known as The Tempest by William Shakespare in 1611. There are two characters in the play, Alonso and Trinculo, who use the expression while speaking to one another:

Alonso. And Trinculo is reeling ripe: where should they
Find this grand liquor that hath gilded 'em? 2355
How camest thou in this pickle?

Trinculo. I have been in such a pickle since I
saw you last that, I fear me, will never out of
my bones: I shall not fear fly-blowing.

It appears that the meaning for the phrase was different back then. Currently, the saying means 'to be in a rough spot,' but the meaning used in the Shakespearean play is simply 'to be drunk.' Accordingly, certain modern English translations for this play render what Trinculo said as: "I have been so drunk since I last saw you," or something along those lines.

This idiom, with its modern meaning, looks to have been used during the mid 17th century. Samuel Pepys, for example, wrote the term down in 1660 in his diary:

"At home with the workmen all the afternoon, our house being in a most sad pickle."

Pepys describes his house as being in a 'sad pickle.' It is doubtful that he would use that term to mean his house was 'drunk.' Rather, it sounds like he's saying his house is messy looking, or in a rough spot, and needs to be cleaned up.
Note: The origins for most phrases and sayings cannot be said with a certainty. What's provided are theories that may be plausible to how a phrase originated, but not necessarily so.

In addition, quotes that contain a particular phrase may be taken from old newspapers, poems, or books that were written centuries ago, but this by no means confirms that the phrase originates from said newspapers, poems, or books. In all likelihood, if an expression is being used in a newspaper, it's probably already a well known saying and is from an older time.
* Stu found himself in a pickle after he ordered for a pizza delivery and then had no money to pay once it arrived!
Know Your Phrase - The Origins And Meanings For Idioms And Phrases > I-Letter Sayings
The meaning of this common expression.
The origins of this saying.