Unclean spirits are those spirit children of God who kept not their first estate, which refers to the life before earth life. All men and women lived with God as his spirit children before coming to the earth as mortal beings. Those who kept their first estate were rewarded with a chance to live on Earth, receive a mortal body, be resurrected, and obtain salvation. Those who keep their second estate (on Earth) shall be exalted. Unclean Spirits, or Evil spirits, are those who did not keep their first estate, and will never receive a mortal body.
The Book of Abraham gives us the most detailed information about our life before the creation of the Earth:
22 Now the Lord had shown unto me, Abraham, the intelligences that
were organized before the world was; and among all these there were
many of the noble and great ones;
23 And God saw these souls that they were good, and he stood in the
midst of them, and he said: These I will make my rulers; for he stood
among those that were spirits, and he saw that they were good; and he
said unto me: Abraham, thou art one of them; thou wast chosen before
thou wast born.
24 And there stood one among them that was like unto God, and he said
unto those who were with him: We will go down, for there is space
there, and we will take of these materials, and we will make an earth
whereon these may dwell;
25 And we will prove them herewith, to see if they will do all things
whatsoever the Lord their God shall command them;
26 And they who keep their first estate shall be added upon; and they
who keep not their first estate shall not have glory in the same
kingdom with those who keep their first estate; and they who keep
their second estate shall have glory added upon their heads for ever
and ever.
27 And the Lord said: Whom shall I send? And one answered like unto
the Son of Man: Here am I, send me. And another answered and said:
Here am I, send me. And the Lord said: I will send the first.
28 And the second was angry, and kept not his first estate; and, at
that day, many followed after him.
That second angel, who was angry, and kept not is first estate, was Lucifer, Satan, the Devil, and those who followed after him; that third part who of the host of heaven who will never have a body of their own, and shall be cast our into outer darkness.
3 And there appeared another wonder in heaven; and behold a great red
dragon, having seven heads and ten horns, and seven crowns upon his
heads.
4 And his tail drew the third part of the stars of heaven, and did
cast them to the earth: (Revelations 12:3-4)
...for, behold, the devil [...] rebelled against me, saying, Give me
thine honor, which is my power; and also a third part of the hosts of
heaven turned he away from me because of their agency; And they were
thrust down, and thus came the devil and his angels; (Doctrine and
Covenants 29:36-37)
And the angels which kept not their first estate, but left their
own habitation, he hath reserved in everlasting chains under darkness
unto the judgment of the great day. (Jude 1:6)