According to Mormons, how did the unclean spirits sin by "not keeping the first estate"? The top-rated answer to this question refers to the Mormon thought on pre-existence as it says:


  All men and women lived with God as his spirit children before coming
  to the earth as mortal beings.


and


  Unclean spirits are those spirit children of God who kept not their
  first estate, which refers to the life before earth life.


According to the LDS faith, our spirits existed in heaven (referred to as the first estate) before we were born here on earth.

Since all humans have, according to LDS faith, left the first estate in order to be born as humans, how did the unclean spirits sin by not keeping their first estate?
Leaving the "first estate" is not the same as not keeping it.

The confusion may come from the Bible in the Book of Jude:


  6 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.


But we get greater clarity from Abraham 3, where it says:


  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.


So those who "kept not their first estate" are those who followed Lucifer and did not obtain physical bodies. The sin that they committed in the antemortal existence was to rebel against God. Merely leaving God's presence and coming to Earth is not itself a sin (although it is a kind of death, since it is separation from God; see the doctrine on the Fall for more about this).