The world is not as evil as it could be – for one reason – the One Who restrains evil, so how does the Holy Spirit restrain evil in the world?
The Holy Spirit
The Holy Spirit may be called holy because of His work in our lives. He strives to make us holy, but He also works in the world by restraining evil. You think it’s an evil world now? Think about the time when the Holy Spirit is taken out of the world! When Jesus was telling His disciples  that He was going to return to the Father, He promised them a Helper or Advocate, and that Advocate is the Holy Spirit, Who, like Jesus, is God. Jesus said Helper would convict the world of sin, saying, “the Helper, the Holy Spirit, whom the Father will send in my name, he will teach you all things and bring to your remembrance all that I have said to you” (John 14:26), and “when the Helper comes, whom I will send to you from the Father, the Spirit of truth, who proceeds from the Father, he will bear witness about me” (John 15:26), but He also has another work that He does, and it’s His work in the world. Jesus said, “when the Helper comes, whom I will send to you from the Father, the Spirit of truth, who proceeds from the Father, he will bear witness about me concerning sin, because they do not believe in me; concerning righteousness, because I go to the Father, and you will see me no longer; concerning judgment, because the ruler of this world is judged” (John 16:8-11), but “Nevertheless, I tell you the truth: it is to your advantage that I go away, for if I do not go away, the Helper will not come to you. But if I go, I will send him to you” (John 16:7), so the Holy Spirit not only helps us, but He also convicts the world of sin, and it doesn’t specifically say He convicts only believers, but He convicts the world of sin. In other words, the Holy Spirit is in the world convicting the world that some things are clearly sin, and by doing so, He restrains evil from being worse than it already is. We know that mankind has no excuse because they only suppress the knowledge of God and deny the obvious existence of God (Psalm 14:1-2; Rom1:20-22), so the Holy Spirit is at work, even now, convicting the world of sin, but He’s also at work in believers since He convicts us of our sin in the hopes that we’ll confess it and repent of it.
The Human Conscience
The word “conscience” means “with knowledge,” so the human conscience has knowledge, particularly of right and wrong. The Apostle Paul wrote, “For the wrath of God is revealed from heaven against all ungodliness and unrighteousness of men, who by their unrighteousness suppress the truth. For what can be known about God is plain to them, because God has shown it to them” (Rom 1:20-21). For one thing, God’s “invisible attributes, namely, his eternal power and divine nature, have been clearly perceived, ever since the creation of the world, in the things that have been made. So they are without excuse” (Rom 1:22). So only “The fool says in his heart, “There is no God.” They are corrupt, they do abominable deeds; there is none who does good” (Psalm 14:1), and it is foolish to deny God’s existence because “The heavens declare the glory of God, and the sky above proclaims his handiwork. Day to day pours out speech, and night to night reveals knowledge” (Psalm 19:1-2). I have noticed that even animals have guilt when they’ve disobeyed. We came home one time and the dog had somehow gotten into the bag of cat food, and the bag was ripped to shreds and there was cat food everywhere…and when we found the dog, who was hiding under the bed, we knew it was him because he acted guilty as sin…and he was, so when unbelievers choose to do evil, they really know better and have no excuse. They simply choose the evil over the good, therefore, they are without excuse.
The Holy Spirit
The Holy Spirit is obviously sent into the world to convict us of our sins, but also convicts the world of sin, and He also suppresses evil in the world by His work in their conscience.  Even in Paul’s day, there was a spirit of disobedience at work, just as there is today, but the Day of the Lord was his subject in writing to the church at Thessalonica, and Paul said, Jesus “will not come, unless the rebellion comes first, and the man of lawlessness is revealed, the son of destruction, who opposes and exalts himself against every so-called god or object of worship, so that he takes his seat in the temple of God, proclaiming himself to be God” (2 Thess 2:-4), but for now, Paul seems to indicate that the church already knows this, writing, “And you know what is restraining him now so that he may be revealed in his time. For the mystery of lawlessness is already at work. Only he who now restrains it will do so until he is out of the way. And then the lawless one will be revealed, whom the Lord Jesus will kill with the breath of his mouth and bring to nothing by the appearance of his coming” (2 Thess 2:6-8). When the One who restrains, Who is the Holy Spirit, is taken out of the way, all hell will literally break loose, but this will only be for a short time, relatively speaking, because “the Lord Jesus will kill with the breath of his mouth and bring to nothing by the appearance of his coming” (2 Thess 2:8).
God also uses human authority to suppress evil, as Paul writes in Romans 13, that “whoever resists the authorities resists what God has appointed, and those who resist will incur judgment” (Rom 13:2), “for he is God’s servant for your good. But if you do wrong, be afraid, for he does not bear the sword in vain. For he is the servant of God, an avenger who carries out God’s wrath on the wrongdoer” (Rom 13:4) so God restrains evil by using human authorities, but also the Holy Spirit, Who convicts the world of sin, so when He is removed, it will be worse than the days of Noah when “ The Lord saw that the wickedness of man was great in the earth, and that every intention of the thoughts of his heart was only evil continually” (Gen 6:5), and “the earth was corrupt in God’s sight, and the earth was filled with violence. And God saw the earth, and behold, it was corrupt, for all flesh had corrupted their way on the earth” (Gen 6:11-12). It is not much different today. Mankind is constantly thinking up new ways to sin, but it could be worse, and it will be worse, when the Spirit of God is removed and so too is the church. By then, we’ll be glad to be out of this world and be with the Lord.
Read more about the Holy Spirit here: Who of What is the Holy Spirit? 
Resource – Scripture quotations are from The Holy Bible, English Standard Version® (ESV®), Crossway Bibles. (2007). ESV: Study Bible : English standard version. Wheaton, Ill: Crossway Bibles. Used by permission. All rights reserved.