The invention of the cotton gin, being one of the most significant developments of the nineteenth century, had turned cotton cloth into an affordable commodity; it was costly before that.
A. being one of the most significant developments of the nineteenth century, had turned cotton cloth into an affordable commodity; it was costly before that
B. having been one of the most significant developments of the nineteenth century, turned cotton cloth into an affordable commodity, costly previously
C. one of the most significant developments of the nineteenth century, turned cotton cloth into an affordable, however costly previously, commodity
D. one of the most significant developments of the nineteenth century, turned cotton cloth into an affordable commodity, whereas it had previously been costly
E. being one of the most significant developments of the nineteenth century, turned cotton cloth from a previously costly commodity to an affordable one
The OA is D, however how is 'it' not ambiguous in the sentence. 'it' can refer to commodity, cotton cloth.