I believe Satan was there in the beginning. He was Lucifer, the anointed cherub, one of the sons of God as mentioned in Job 38.
Job 38
4 Where wast thou when I laid the foundations of the earth? declare, if thou hast understanding.
5 Who hath laid the measures thereof, if thou knowest? or who hath stretched the line upon it?
6 Whereupon are the foundations thereof fastened? or who laid the corner stone thereof;
7 When the morning stars sang together, and all the sons of God shouted for joy?
***WARNING*** Long Read
Apparently at this time, Lucifer had not sinned. There is a great time span between Gen 1:1 and Gen 1:2. During this period, Lucifer rebelled...
Isa 14:12 "How you are fallen from heaven, O Lucifer, son of the morning! How you are cut down to the ground, You who weakened the nations!
Isa 14:13 For you have said in your heart: 'I will ascend into heaven, I will exalt my throne above the stars of God; I will also sit on the mount of the congregation On the farthest sides of the north;
Isa 14:14 I will ascend above the heights of the clouds, I will be like the Most High.'
Eze 28:12 "Son of man, take up a lamentation for the king of Tyre, and say to him, 'Thus says the Lord GOD: "You were the seal of perfection, Full of wisdom and perfect in beauty.
Eze 28:13 You were in Eden, the garden of God; Every precious stone was your covering: The sardius, topaz, and diamond, Beryl, onyx, and jasper, Sapphire, turquoise, and emerald with gold. The workmanship of your timbrels and pipes Was prepared for you on the day you were created.
Eze 28:14 "You were the anointed cherub who covers; I established you; You were on the holy mountain of God; You walked back and forth in the midst of fiery stones.
Eze 28:15 You were perfect in your ways from the day you were created, Till iniquity was found in you.
Eze 28:16 "By the abundance of your trading You became filled with violence within, And you sinned; Therefore I cast you as a profane thing Out of the mountain of God; And I destroyed you, O covering cherub, From the midst of the fiery stones.
Eze 28:17 "Your heart was lifted up because of your beauty; You corrupted your wisdom for the sake of your splendor; I cast you to the ground, I laid you before kings, That they might gaze at you.
Eze 28:18 "You defiled your sanctuaries By the multitude of your iniquities, By the iniquity of your trading; Therefore I brought fire from your midst; It devoured you, And I turned you to ashes upon the earth In the sight of all who saw you.
During this rebellion, The earth was destroyed. It became tohu and bohu, as translated in the NKJV as chaos and confusion.
Gen 1:2 The earth was without form, and void; and darkness was on the face of the deep. And the Spirit of God was hovering over the face of the waters.
Now ALL the sons of God, which included Lucifer, didn't shout for joy for the scene described in Gen 1:2 and God is not the author of confusion...
1Co_14:33 For God is not the author of confusion but of peace, as in all the churches of the saints.
The earth was created beautiful, Satan wrecked it and Gd recreated it beautiful. During the Millennium, the whole earth will be made like the garden again by the resurrected saints...
Rom 8:19 For the earnest expectation of the creation eagerly waits for the revealing of the sons of God.
Rom 8:20 For the creation was subjected to futility, not willingly, but because of Him who subjected it in hope;
Rom 8:21 because the creation itself also will be delivered from the bondage of corruption into the glorious liberty of the children of God.
Rom 8:22 For we know that the whole creation groans and labors with birth pangs together until now.
Rom 8:23 Not only that, but we also who have the firstfruits of the Spirit, even we ourselves groan within ourselves, eagerly waiting for the adoption, the redemption of our body.
The word adoption in verse 23 should rightly be translated sonship or even birth. Thos God has called now and are baptized and converted are begotten with the Holy Spirit. At the resurrection we will be born into the family of God.