“from going back and forth on the earth.” This meeting of spirit beings occurs in heaven. The “sons of God,” who came to present themselves before Yahweh were spirit beings that were directly created by God, in fact, some versions translate them as “angels” (cp. NIV), and the NLT translates the phrase as “members of the heavenly court.” That heaven is the location of this meeting can be ascertained because when Satan comes, along with other spirit beings, to present himself before Yahweh, Yahweh asks where he came from, and Satan said he came “from” the earth.
Although the fullness of Satan’s power and army of demons is not revealed in the Old Testament like it is in the New Testament, the power of Satan as the “god of this age” (2 Cor. 4:4), the “ruler of the power of the air” (Eph. 2:2), and the “ruler of this world” (John 12:31) can be clearly seen as he works his evil against Job. He marshals evil armies (Job 1:15, 17), causes destructive storms (Job 1:16, 19), and causes sickness and disease (Job 2:7). He does these things as a free will being at war with God, and one day he and his work will be destroyed.
It is noteworthy that Satan says he had been going back and forth on the earth, because 1 Peter 5:8 says Satan walks around seeking someone to devour. Note that Satan does not say why he was on earth or what he was doing there. He was up to no good, but being a liar he would not reveal that to God and His created spirit beings (but they likely knew it anyway).
[For more on the “sons of God” being spirit beings who were created by God, see commentary on Gen. 6:2].