In Mormonism: In the Pre-Earth life, everyone lived with Heavenly Father and Jesus Christ. The earth wasn't created yet.
In a particular time, Heavenly Father gathered us around, and told us that we will go into a world and be tested. He needed someone to be the one to atone for every one's sins. (no unclean person who sinned, even once could come back to Heavenly Father unless someone atones for the sins) One of His son's, Lucifer, said that he will be the one. He will force everyone to be perfect, and make sure that everyone will come back. Lucifer only wanted Heavenly Father's power, he did not care about the others. Another one of His sons, Jesus Christ, said that he will atone for their sins, and allow everyone to have free agency. Heavenly Father chose Jesus to be the one. Lucifer was angry, and stirred many souls to join him. Heavenly Father had to cast out Lucifer and his followers, around 1/3 of His children. Today, Lucifer is known as Satan, and he and his followers were cursed by not allowed to enter earth with a body of flesh and blood. They work endlessly, trying to ruin and destroy Heavenly Father's Plan.
Jesus Christ, instructed by Heavenly Father, created the Earth and the Heavens in six "days." (probably much longer in human time)