I know that both of these expressions are correct, but I'd like to be able to explain exactly why the first one is correct. Of course compound adjectives are hyphenated (second expression), but in the first expression, exactly what parts of speech are "20" and "meters"? Is "20 meters thick" a predicate adjective that is not hyphenated because it's a predicate rather than an attributive adjective phrase that precedes the noun "layer"? Is "20" an adjective? This is so intuitive that I can't articulate the rules behind it -- but I need to for a scientific colleague.
Perhaps a clearer way to explain the distinction might be to compare "It's a 20-meter-thick layer" with "The layer is 20 meters thick"—which is the sense of "It's 20 meters thick" once you identify the intended referent for the pronoun It that appears at the beginning of that sentence. With
The layer is 20 meters thick.
we know what the subject is from the outset because the writer opens the sentence with it ("The layer"). So all that remains in the predicate is the modifier of the subject that we encountered at the beginning of the sentence: The layer is thick. How thick? 20 meters thick. There is no point in hyphenating the modifying phrase here because the predicate is simple enough that the sense of its components can't easily be misunderstood.
In contrast, with
It's a 20-meter-thick layer.
We don't know what the pronoun It refers to until we reach the last word of the sentence, where layer appears as a predicate nominative, and "20-meter-thick" modifies it. For the reader, unraveling the sentence involves working through this path: It's a layer. What kind of layer? A 20-meter-thick layer. Here some writers would hyphenate "20-meter-thick" to make immediately clear that that part of the predicate forms a modifying block for the predicate nominative.
Compound modifiers are hyphenated. The hyphenated example is a compound modifier of the noun "layer."
A 20-foot-thick layer. A 20-story-tall building. A 3-year-old girl.
But: The layer is 20 feet thick. The building has 20 stories. My daughter, who is 3, is named Julie.
(Reference for compound modifier and hyphenation of ages is from the Associated Press Stylebook (formerly "Manual of Style")
I am by now means an English major so I don't know the right terms. I will do my best to explain what I see.
In the first sentence, "20 meters" adds to the the existing adjective which is "thick" and all of that together characterizes the "It". And you can remove it.
Same exact meaning (but with less detail).
In the second example "20-meter-thick" is the adjective for "layer".
The construction of the two phrases are different so the compassion is redundant, not sure why you even bring the second example up.
It = Noun
's (is) = Verb
20 meters = Adjective for adjective (?)
thick = Adjective