That phrase is a derogatory alternative name for the economy coined by the Victorian historian Thomas Carlyle in the nineteenth century. The term created a contrast with the then familiar use of "la gaya ciencia" to refer to the composition of songs and verses
Because Thomas Carlyle who was a writer and philospher, made up the phrase that economics is "dismal science" (dismal meaning depressing) because he believed that humans are trapped in a world where population will always grow and limit natural resources and bring widespread misery.