Sin existed before the world began when a group of angels (primarily the one called Lucifer) desired to be equal with God and consequently were thrown out of heaven. Sin then entered the world through the agency of man’s unbelief and disobedience according to God’s perfect will and providence.
Paul writes in Romans that “sin came into the world” (5:12) which confirms that it already existed and did not originate in the world. It is indeed with the angels that we find the origin of sin: “For if God did not spare the angels when they sinned, but cast them into hell…” (2 Peter 2:4) and “the angels who did not stay within their own position of authority, but left their proper dwelling…” (Jude 6). Bavinck writes, “He (Lucifer) became discontented with his status and power on his own, by his own thinking; he produced the lie from within himself and projected it as a realm, a system over against the truth of God.” Sin then entered the world when Satan (Lucifer) tempted man, who being a rational creature with a free will, fell into the temptation, thus becoming the agent of sin in the world. Man was created morally upright but had mutable freedom and “under a possibility of transgressing, being left to the liberty of (his) own will…” (WCF 4:2). The origin of sin and the entrance of it into the world is completely under the control and authority of God’s decree and providence. There are some who believe if God created everything and is in control of the universe then He must be the author of sin. This is absolutely false. First, theology always discusses God and everything in relation to God. God, in his divine goodness, cannot act against his nature (Psalm 119:68; James 1:17-18). Second, his nature is immutably, purely, and effusively good, thus sin cannot originate from God (Heb 1:3, Rev 4:11, Matt 11:25-27; I John 1:5). Third, James chapter 1 confirms that God is not the author, but the agent of testing (James 1:2-4, 13-14; 5:11).
The “author of testing” brings us to God’s providence. Through providence God sustains, governs, and cooperates with creatures. According to John Frame, providence is a type of revelation and comes under the Lordship attribute of authority. The Westminster Confession (3:1, 5:4) states that God is not the author of sin but that he ordains it and uses it for his good purpose (i.e. having authority over it). Frame describes four areas of providence: government, preservation, concurrence, and revelation. The relationship of the origin of sin with providence is best considered under concurrence, which is the cooperation of primary causes and secondary causes in the world. If I throw a marker and poke someone’s eye out, the ability to throw the marker is the primary cause, which comes from God and the intention of hurting this person and act of throwing it is the secondary cause, which comes from man. John Calvin describes the primary cause as remote and the secondary cause as proximate.  The secondary cause cannot work without the primary cause. Unless I have the ability to throw the marker from God (primary cause), I can’t follow through with the act. Robert Reymond writes that the primary cause is the foreknowledge and decree of God.  And, “God’s will is based on his knowledge and his knowledge is based on his will”, concludes Frame.  The author / character model of Frame is the best description of God’s providence that I have come across. The author writes a script but it is actually the characters in the play that act out. The author does not do the acting, the author just allows and has authority over the script. Thus, the author is the primary cause and the characters are the secondary cause. 
Everything, including sin and evil, works to God’s appointed end (2 Chron 18:21, Rom 1:18, 8:28, Acts 2:23-24, Gal 3:10-14). His will and foreknowledge work simultaneously to have authority over this world. “He (God) deemed it better to bring good out of evil than not to permit evil to exist at all.” 
 Bavinck, Reformed Dogmatics Volume 3, 68.
 Lecture Notes
 John Frame. Doctrine of God, 274ff.
 John Frame. Doctrine of God, 274ff.
 John Frame. Doctrine of God, 176.
 Robert Reymond. A New Systematic Theology of the Christian Faith, 398.
 John Frame. Doctrine of God, 151.
 John Frame. Doctrine of God, 156
 Bavinck, Reformed Dogmatics Volume 3, 65 [footnote 104: Augustine, City of God.]