It appears that the term 'dismal science' was first coined by Thomas Carlyle, in December 1849, “Occasional Discourse on the Negro Question” in the London monthly Fraser’s Magazine.
In particular, Carlyle was criticising the economists belief in supply and demand which stood in sharp contrast to his idealised view of a slave society. Carlyle, like many of the Victorian age, considered blacks to be inferior to whites (he referred to blacks as ("two-legged cattle") and therefore these non whites needed the 'beneficient whip' to be useful to society. This view, he held, justified slavery as a model for society, and he criticised those economists and evangelists who believed in equality and freedom of the people. This view on equality was held by thinkers such as John Stuart Mill, Harriet Martineau and Charles Darwin. But, at the time many such as Carlyle, Dickens and Alfred Tennyson did not hold this belief.
Carlyle's view on Economics was
"quite abject and distressing...dismal science...led by sacred cause of Black Emancipation."
Thus in a nutshell, Carlyle dislike economics because of its support for black emancipation and the ending of slavery
Dismal Science and MalthusCarlyle also was critical of T.Malthus, view on over population. In an essay on Chartism 1839, Carlyle wrote
"The controversies on Malthus and the 'Population Principle', 'Preventative Check' and so forth, with which the public ear has been deafened for a long while, are indeed sufficiently mournful. Dreary, stolid, dismal, without hope for this world or the next, is all that of the preventative check and the denial of the preventative check."It is this that helped make a link between Economics and 'the Dismal Science'. But, it is worth remembering that in this quote he only referred to the 'dismal' prophecies. The origin of the term, 'dismal science' came about also because of the opposition of economists to slavery as a morally superior state of affairs.