We prove a Cohen-Macaulay version of a result by Avramov-Golod and Frankild-Jørgensen about Gorenstein rings, showing that if a noetherian ring A is Cohen-Macaulay, and a1,…,an is any sequence of elements in A, then the Koszul complex K(A;a1,…,an) is a Cohen-Macaulay DG-ring. We further generalize this result, showing that it also holds for commutative DG-rings. In the process of proving this, we develop a new technique to study the dimension theory of a noetherian ring A, by finding a Cohen-Macaulay DG-ring B such that H0(B)=A, and using the Cohen-Macaulay structure of B to deduce results about A. As application, we prove that if f:X→Y is a morphism of schemes, where X is Cohen-Macaulay and Y is nonsingular, then the homotopy fiber of f at every point is Cohen-Macaulay. As another application, we generalize the miracle flatness theorem. Generalizations of these applications to derived algebraic geometry are also given.