To understand demons, we have to first understand their leader, Lucifer. The hierarchies of authority that we have in life originated in the supernatural. We have kings, presidents, governors, senators, generals, lieutenants, sergeants, CEO's, managers, assistant managers, fathers, mothers, and the list goes on. We are all submissive to another person in our lives from the time we are babies to the day we die.
Well, evil spirits are also submissive to their king–Lucifer, otherwise known as Satan. Scripture supports the idea that they too have an authority structure of their own.
For we wrestle not against flesh and blood, but against principalities, against powers, against the rulers of the darkness of this age, against spiritual forces of evil in the heavenlies. – Ephesians 6:12, EMTV
Humanity is constantly at war with structured supernatural forces, each with different positions of authority, and ultimately controlled by Satan himself. Of course this doesn't answer the question of how they got their beginnings.
Before we had our beginnings as humans, the "devil" and demons were already around in the heavenly realms, but they weren't always referred to in those terms. They were originally created as angels, right along with Gabriel (Daniel 8:16; 9:21; Luke 1:19, 26) and Michael (Daniel 10:13,21; 12:1; Jude 1:9; Rev. 12:7). Michael himself is referred to as either a prince or archangel.
The supernatural master of evil we know today as Satan was originally one of God's closest angels, when studying him from a biblical perspective:
Thus says the Lord GOD: "You were the signet of perfection, full of wisdom and perfect in beauty. You were in Eden, the garden of God; every precious stone was your covering, … You were an anointed guardian cherub. I placed you; you were on the holy mountain of God; in the midst of the stones of fire you walked. You were blameless in your ways from the day you were created, till unrighteousness was found in you. In the abundance of your trade you were filled with violence in your midst, and you sinned; so I cast you as a profane thing from the mountain of God, and I destroyed you, O guardian cherub, from the midst of the stones of fire. Your heart was proud because of your beauty; you corrupted your wisdom for the sake of your splendor. I cast you to the ground. – Ezekiel 28:12-17a, ESV
Those verses are a picture of Lucifer as he was from the beginning of his creation as a beautiful guardian angel to the point where he was cast out of heaven for becoming proud of his beauty. He had somehow developed the attitude that he wanted to rise to at least the same stature as God.
How you are fallen from heaven, O Lucifer, son of the morning! How you are cut down to the ground, you who weakened the nations! For you have said in your heart: ‘I will ascend into heaven, I will exalt my throne above the stars of God; I will also sit on the mount of the congregation on the farthest sides of the north; I will ascend above the heights of the clouds, I will be like the Most High.’ Yet you shall be brought down to Sheol, to the lowest depths of the Pit. – Isaiah 14:12-15, NKJV
We can't understand how angels had the capacity within themselves to sin against God anymore than we can understand how Adam and Eve had the capacity to disobey God. All we can accept is that God gave both angels and humanity the free will to obey Him or seek their own desires. Both failed the test at some point. In the above reference, Lucifer wanted to exalt his throne above the stars of God. Stars are many times a reference to angels of God. They are sometimes called the host of heaven as well. So Lucifer actually did exalt his throne above a large number of the stars (angels) of God. The Bible teaches that one-third of God's angelic force followed in Lucifer's heavenly rebellion. I can't even comprehend that so many of God's holy angels would use their free will to turn against their Creator.
And there came to be war in heaven: Michael and his angels, waging war with the dragon; and the dragon made war, and his angels, and he did not prevail, nor was a place found for him any longer in heaven. And the great dragon was cast out, that serpent of old, called the Devil and Satan, who deceives the whole world; he was cast to the earth, and his angels were cast out with him. Then I heard a loud voice in heaven saying, "Now have come the salvation and the power and the kingdom of our God, and the authority of His Christ, because the accuser of our brothers, the one who accused them before our God day and night, has been thrown out of heaven. – Revelation 12:3-10, EMTV
That set of verses is actually talking about the final casting out of the devil and his demons from the heavenly realms before the 2nd coming of Jesus Christ yet to come. We know from the story of Job that Satan still had the right to appear in heaven throughout the generations of humanity (Job 1:6,7; 2:1,2) even after he was first cast out of heaven. But the above verses do show us that one-third of God's angels had originally followed in the heavenly rebellion. Otherwise, they would not be getting finally cast down in the end days.
So that's how demons got their start in being the supernatural promoters of evil that they are known for today. Stop back any time to see how they are the cause of the world's evil and death itself.