I guess forests have seemed to be deep, dark, and dangerous for a long time. To say “We’re not out of the woods” is to say we remain in trouble, that we have not overcome “a dangerous, perplexing, or difficult situation.” dictionary.com
Abigail Adams used the expression in a November, 1800 letter found in Papers of Benjamin Franklin (ginger) but the phrase seems to be much older, though I didn’t find the specific citations:
This expression, alluding to having been lost in a forest, dates from Roman times; it was first recorded in English in 1792. dictionary.com