Unlike Carl Großmann and Fritz Haarmann, Denke wasn't a sexual maniac, even if he was mentally retarded. His behavior seems rational to some extent. He killed only beggars and vagabonds. His acquaintances and neighbors knew he sold meat products and traded second hand clothes, they thought however, that as a farmer's brother he must have had easy access to pork and veal.
In order to understand Denke's motives at least partially, it is necessary to consider his acts from a broader perspective. The fact that he had been murdering beggars and vagabonds is in my opinion crucial. His later years coincide with the collapse of the old world order, symbolized by the Austro-Hungarian Empire. That world perished in the trenches of the First World War. A new axiological, political and social paradigm was yet to be invented. The post-war period was marked by a tremendous turmoil, from which emerged such ideas as fascism, communism etc. This was also the time of a primitive positivism in science. The latter was meant to bring happiness, peace and wealth to all. The assumption that science can bring answers to all possible questions became a form of religion, but confronted with the prevailing ideology of the time - nationalism - it gave birth to a very dangerous "science": eugenics.
This person suffering from hereditary defects costs the community 60,000 Reichsmark during his lifetime. Fellow Germans, that is your money too"
The idea of selective reproduction of people became popular among some scientists and politicians of many Western countries in the late XIXth and early XXth Century. Germany wasn't an exception. Eugenics were applied long before the Nazis seized power in 1933. It is worth noticing that Karl Binding's and Alfred Hoche's book Die Freigabe der Vernichtung Lebensunwerten Lebens (Release for Annihilation of Life Unworthy of Life) was first published already in 1920. Beggars and vagabonds became one of the first victims of eugenic policies in the Weimar Republic. However eugenics was not only a scientific theory of that time. It reflected the atmosphere of the time.
Karl Denke - a man of very limited intellectual capacity - couldn't obviously understand the scientific language and philosophical or social implications of eugenics, but he could understand that beggars and vagabonds were a threat to a healthy society, they were a problem - he concluded - just like parasites. Some villages in Lower Silesia officially issued laws to expel them from the communities. Denke must have been aware of that, so he had found a simple solution to the problem: by killing the vagabonds, he would help the local authorities and make some money by selling their flesh. From a certain point of view, he wasn't even a cannibal, because he didn't consider his victims as humans.