The human author of Book of Job I believe received a vision and overheard a conversation and through God's grace gave him the wisdom to write the inspiration for purpose of stating that all the action of Satan are subject to Divine Providence. As St. Augustine said," if God will not restrict the action of the devil with his fury & hatred no man will be alive in a matter of time".
This writing can be paralleled to event that took place in 1884 when Pope Leo XIII had a vision of Satan talking to God. In that vision Satan was daring God that he can destroy the Catholic Church. But to do so,Satan ask for more power and more time (75 to 100 years). This vision leads to the formulation of St.Michael the Archangel Prayer to be prayed right after the Holy Mass celebration.
These two events: one in the Book of Job, the other in the vision of Pope Leo XIII.
Catechism of the Catholic Church teaches that God allows evil for greater good of man. As scriptures said "all things work for good for those who love him"
Like in the Garden of Eden, God allows Satan for the perfection of man. Man & Church will always be put to the test to attain a greater good, but as St. Paul with the temptation God will never put us to the test beyond our human strength to endure, and God will always give a way out.
CCC 412 But why did God not prevent the first man from sinning? St. Leo the Great responds, "Christ's inexpressible grace gave us blessings better than those the demon's envy had taken away." And St. Thomas Aquinas wrote, "There is nothing to prevent human nature's being raised up to something greater, even after sin; God permits evil in order to draw forth some greater good. Thus St. Paul says, 'Where sin increased, grace abounded all the more'; and the Exsultet sings, 'O happy fault,. . . which gained for us so great a Redeemer!'"
After Job passed the test, God rewarded Job with more blessings.