The Bavli records in many places the existence of demons, and answers to this question cite rishonim and acharonim who take this seriously. Pesachim 112b relates a story in which demons are (initially) allowed to wreak havoc in the world at any time. (They are later limited to specific times.)
What is the purpose of these demons and their havoc-wreaking? Humans have free will and can thus act badly, but demons are not humans and I understand that only humans have free will. Demons are also not natural occurrences; earthquakes, tornados, etc. also wreak havoc, but that's built into the fabric of the universe that God created. And as far as I can tell (I may be wrong on this) demons are not acting on specific divine orders the way ha-satan does.
So what purpose do they serve? Why did God create them and allow them to act in the world?