Your question had me as perplexed as Habakkuk! Not knowing the answer I found an article on the subject, the essence of which goes something like this:
When Habakkuk says that God’s “eyes are too pure to look on evil” we have to read it in the context of the larger discussion. Habakkuk understands the righteous character of God. He also knows that the nation is full of sin but he can’t understand why the wicked prosper and the righteous suffer. It looks like God is tolerating sin and wickedness and Habakkuk wants to know why God was seemingly slow to administer justice.
God informs Habakkuk that he plans to use the Babylonians to conquer Judah and punish the evildoers, but the Babylonians are even more sinful and wicked than God’s people! Does God approve of their sin? That’s why Habakkuk says, “Your eyes are too pure to look on evil; you cannot tolerate wrong”.
In this instance, “to look on” equates with “tolerate.” Take the word “countenance” – it can mean “face” or “look” or “to sanction or approve of”. So why is God looking on sin, wickedness, or evil as if he can countenance it?
When we get to chapter 2 God assures Habakkuk that the sins of Babylon will not be tolerated, either. They were being used as God’s instrument to judge the wickedness of Judah, but the evil deeds of the Babylonians will also come under God’s judgment in His own good time. Source: https://www.gotquestions.org/God-look-upon-sin.html
Going back in time to the day that Satan presented himself before God and God asked Satan what he thought of Job, Satan accused Job of honouring God only because God had blessed him. So, God allowed Satan to take away Job’s wealth and his children. God looked upon Satan and God knew Satan was evil. He has been evil “from the beginning” (thanks, Nigel). But God was not condoning or tolerating evil. Like the Babylonians, God used Satan as a means to His own ends and purposes.
There is a powerful lesson from both events – judgment starts with God’s people. We do well to wake up to what’s going on in the world right now and pay heed. Is it okay for me to say that?