I am primarily interested in two questions about the phrase "den of iniquity":
1. When and where did the phrase first appear in print?
2. When and under what circumstances did it become a popular expression?
The phrase has a biblical timbre (to my ear), so I initially thought that it might have appeared somewhere in the King James translation of the Bible—or, failing that, in a passage from The Pilgrim's Progress or perhaps Paradise Lost.
But in doing some preliminary research on its origin, I was surprised to find that "den of iniquity" appears exactly once in Early English Books Online search results (which cover the period from 1475 through 1700): in Thomas Brooks, The Crown & Glory of Christianity: Or Holiness, the Only Way to Happiness: Discovered in LVIII Sermons, from Heb. 12. 14 (1662):
Mark, though the people of God were to keep themselves from every wicked thing, at all other times, yet when they went out against their enemies, then in a special manner it highly concerned them to keep themselves not from some, but from every evil thing, or rather as the Hebrew hath it, from every evil word, דָבַר Dabar, hee that is in danger of death every step hee takes, and that carries his soul in his hand, had need precisely to abstain not onely from every evil work, but also from every evil word, as here God expressly charges Israel to do. When God finds holiness in Israels Camp then God will quickly give up Israel's enemies into Israels hands; but when the Camp becomes a Den of iniquity, then God will depart from the Camp; and when God who is the bulwrk of a Camp, is departed, all the world cannot preserve that Camp from being destroyed.
Moreover, the earliest legitimate Google Books match for "den[s] of iniquity" following the one from Brooks cited above is from the fourth edition of a book published some four decades later. From Patrick Gordon, Geography Anatomiz'd: Or, The Geographical Grammar: Being a Short and Exact Analysis of the Whole Body of Modern Geography, fourth edition (1704):
But so fully accomplisht is the Prophetical Denunciation against 'em both [the cities of Tyre and Sydon], and so low and despicable is their Condition at present, that I heartily wish all flourishing Cities of Christendom might be so wise, as seriously to reflect on the same, and to take timely warning by them; especially considering, that most of our Populous and Trading Cities, are now such Dens of Iniquity, that their Inhabitants may justly dread, That 'twill be more tolerable for Tyre and Sydon in the day of judgment, than for them.
Brooks is identified in the byline to his book of sermons as "late Preacher of the Gospel at Margarets New Fish-street, and still Preacher of the Word in London, and Pastor of a Congregation there." This doesn't sound like the sort of eminence that would lead to an outburst of popular enthusiasm for an unusual turn of phrase from the man's pulpit. But Brooks's Wikipedia entry indicates that as a Puritan cleric he "was sufficiently renowned for being chosen as preacher before the House of Commons on 26 December 1648."
Gordon's book, in contrast, went through at least nineteen editions over more than fifty years, so it seems to have been a reasonably popular work. But here, too, the context in which the phrase appears doesn't cause it to leap off the page, and I wonder whether it could be the trigger for widespread adoption of "den of iniquity" as an idiomatic phrase.
One somewhat distant possibility is that "den of iniquity" may have arisen out of an adventitious cross-pollination of "den of thieves" (which occurs in some 435 EEBO-indexed publications before 170o, from as early as 1614) and "burden of iniquity" (which appears in 20 such publications from as early as 1641)—but that hypothesis seems rather unlikely.
The Ngram frequency graph for "den of iniquity" (blue line) and "dens of iniquity" (red line) for the period 1650–2015 suggests that in recent years the expression has reached a level of popularity not seen since the Victorian Era, if then:
!["den[s] of iniquity"](https://i.sstatic.net/TpBUNCEJ.png)