Ravan was the king of Lanka. His prosperity could be judged by the fact that his Lanka - capital city - was built in gold. Everyone had enough of food and shelter. Except for his brother Vibhishan, and to some extent his (Ravan's) wife Mandodari, rest of the people in his kingdom followed Ravan's path of material enjoyment as the goal in life.
He had a huge army to defend his kingdom which was rarely threatened and nobody even imagined or dreamt that it would be. Moreover, the location of his capital was such that outsiders could not venture to reach there, as a sprawling sea separated it from the far-off land.
Ravan was the mightiest king on the earth in his time. He was very learned and accomplished person. He was great devotee of Lord Shiva, and had obtained the boon that he would not be killed by anyone other than the Lord Himself! He was well- versed in Vedas, and other scriptures.
He used to worship Lord Shiva daily. His bravery, courage, and expertise in the use of all types of instruments of war (like bow and arrow, mace, sword, so on) was acknowledged by everyone.
Moreover, he was gifted with special supernatural powers known as Mayawi-Shakti. With its help he could fly in the air, become invisible, could throw rain, fire, or thousands of arrows in a war encounter. He had many other powers granted to him by Brahma God as well. Even then,why call him wicked or evil? This was because he was selfish!
He was interested in using all these powers for himself only, and that too to gratify his senses alone. He did not believe that all spiritual disciplines and worship are meant to seek refuge at the Holy Feet of his Chosen Ideal, but wanted to make use of all such powers to rule over the world as an unconquerable King.
Thus he was full of lust, pride, anger, covetousness, infatuation, hatred, and jealousy. These tendencies, according to our scriptures, cause the downfall of a man and hence such persons are called Demons. They are engrossed in a life- style where they are blind to the values of compassion, kindness, and service.
They practice unrighteousness and do not allow the devotees or sadhaks to pursue their spiritual practices to seek God (or Self or Truth, or Atman or Brahman). Religion takes a downhill course.
Hence God incarnates to destroy them(unrighteous people) in order to establish means and ways of righteousness.That is how Ram incarnated as an Avatar.