The phrase "dismal science" as it applies to economics was introduced by Thomas Carlyle in Occasional Discourse on the Negro Question. In this work, Carlyle argued for slavery and against a free market on moral grounds (of all things). He claimed that the slaves' lives had gotten worse since the end of slavery. More free market oriented economists such as John Stuart Mill disagreed with him. Apparently, he had called Malthus' predictions dismal in an earlier work, so the phrase is erroneously associated with that criticism.
Carlyle was a "law and order" type of person. He regarded the elimination or minimization of government and lords as undesirable and the study of free markets (leaving men to themselves) as a dismal endeavor.