As far as the record shows, the words are John Archibald Wheeler’s, not Einstein’s. In 1979, the centenary of Einstein’s birth, the physicist, who had known Einstein in Princeton, said Einstein’s work “revolved around three rules”: “Out of clutter, find simplicity; From discord make harmony; and finally In the middle of difficulty lies opportunity.” No earlier source has Einstein saying it.
What it means
The hardest part of a problem is often where the most can be gained, so difficulty is a reason to look closer rather than to give up. Wheeler offered it as a rule for science, and for problems in general.
Where it comes from
The fullest early source is an interview with Wheeler in Cosmic Search magazine (vol. 1, no. 4, Fall 1979). Asked whether any of Einstein’s tenets stood out, Wheeler answered that “his work revolved around three rules which apply to all science, our problems, and times”, and listed them: out of clutter, find simplicity; from discord make harmony; and in the middle of difficulty lies opportunity. Quote Investigator found the same three rules in an article by Wheeler in Newsweek on 12 March 1979, introduced as “three additional rules of Einstein’s work that stand out for use in our science, our problems, and our times.”
Wheeler did not say Einstein had spoken these words, and named no letter, lecture or conversation; as Wikiquote notes, he may have been describing how Einstein worked rather than quoting him. Retold as “Einstein’s three rules of work”, the third rule seems to have lost its context and become an Einstein quotation. Quote Investigator tentatively credits the exact wording to Wheeler; The Dictionary of Modern Proverbs (2012) reports citations from 1975, which we have not seen. According to Quote Investigator, The Ultimate Quotable Einstein (2010) lists the line among sayings misattributed to him. The idea itself is much older: Quote Investigator traces “Suggest to yourself an opportunity in every difficulty” to 1903, and “every difficulty is an opportunity” to a 1919 speech by Bertram Carr, Mayor of Carlisle.