Giygas was in possession of the Apple of Enlightenment before the events of Earthbound, where it foretold Giygas's defeat at the hands of a child named Ness. To disprove this prophecy, he initiates his invasion of Earth 20 years before it was prophesied, only to be defeated by Ninten the first time.
The prophecy was still being told at least 10 years into Ness's future where he succeeded in plunging all into darkness, which prompts Buzz Buzz to travel back to Ness's time to warn him. Although it predicted that Ness and his friends would defeat Giygas, Pokey claimed that it never predicted his own involvement with Giygas' plans.
In Earthbound, it's never clearly stated what or who the Apple really is, so there is a theory that it's a manuscript that Apple Kid wrote. This explains why Pokey was never mentioned in the prophecy, since the two never heard of each other. The Japanese original that is clear that the Apple is a "prophecy-telling machine in Gyiyg’s possession [that] has foretold that Gyiyg’s machinations will end in failure" disproves this theory.