I want to know which one of these two sentence structures is correct grammatically:
- This book is, despite being dense, a good read.
- This book, despite being dense, is a good read.
You're trying to convey two facts. The first is that the book is a good read, the second is that this fact is despite the book being dense (that the book is dense, that this can detract from a good read, but that this doesn't happen here).
The first we express with an independent clause:
The second with a dependent clause:
The question you are asking, is where can the dependent clause be placed grammatically.
The two options you have in your question are both doing so parenthetically. That is the commas act the same as parentheses
Now, with your parenthetical use the important thing is:
We can consider the first clause as broken into:
If we broke these parts up with a dependent clause, we damage the independent clause:
The first is clearly wrong because the first damages "this book" to produce "this, despite being dense, book" which makes little sense ("this, admittedly dense, book" would let us express the same thing by altering that noun phrase).
The second, and third break up "a good read". These come up with slightly different meanings - altering the noun phrase to suggest the "read" rather than the book is dense. We've produced something that modifies "read" much as "good" does. Since a book being dense, and it being a dense read is much the same thing, that amounts to the same thing in this case, but could mean something different in another case. They're both also clumsy as per the style decisions we'll talk about later ("a good, though dense, read" would scan better but lose some of the meaning of "despite").
Of the two you put in your answer, neither break components like this. While grammatically different in where they place the parenthetical clause, they are both grammatically valid, and both semantically the same.
So of the four valid options:
The choice remaining is one of style. The main differences are when each thought is brought to the reader, the first two are opposite in terms of what they lead with and what they leave the reader with. Hence the first leaves the reader with the focus on density, the second with the focus on the enjoyable quality.
Of the two you had, there is less to choose between them. Both make the density less a focus than the others, by making it parenthetical, so these are the ones to go for if you want the emphasis to be on the "good read". The first of yours helps encourage the reader on, because we know something must come after the is in the main statement and we read on to find out what it is, it also makes the concept "a good read" stand out on its own a bit more. The second though slightly emphasises assertion that it is "a good read" by having it immediately follow that verb.
These differences are subtle matters of impression, again they are semantically the same, so its a matter of taste and style, rather than grammar and meaning, to pick between them.
Both are difficult to read and in general it is best to avoid such writing style.
It is clear you have some concerns about the book but like it overall. Maybe it is actually better to write 2-3 easier sentences that convey the same meaning, and in the process elaborate on the good parts and also not so good parts. Dense = too many difficult words? Too many subjects / topics in a short time? Elaborating on these points helps get the reader more into what you are thinking and leaves few questions to the user...