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 this phrase was different back then. Currently, the saying means 'to be in a rough spot,' but the meaning used in Shakespearear's play is simply 'to be drunk.' Accordingly, certain modern English translations for the 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 like it used as early as 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 was 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.
* Steve was hungry and decided to order a pizza, but he found himself in a pickle after the pizza arrived and he had no money to pay with.