Short anwer
Here, gesetzlich is not declined, because it is used as an adverb, not as an adjective.
Adjective
the legal allowed cases → den gesetzlichen zugelassenen Fällen
Here, the cases are allowed and legal. Therefore, both zugelassenen (allowed) and gesetzlichen (legal) are adjectives, which must be appropriately declined.
Adverb
the legally allowed cases → den gesetzlich zugelassenen Fällen
Here, however, the the cases are legally allowed. Therefore, gesetzlich (legally) is an adverb that modifies the adjective zugelassenen (allowed). German adverbs are not declined.