In the beginning, before space, time or even the elements, there was only an egg.* This egg hatched to reveal Arceus who took the fragments of the eggshell and formed four new eggs from them. From these eggs hated Dialga, Palkia, Giratina, and Unova **. The five looked at the nothingness around them and decided to make something out of it.
Dialga created time, Palkia created space, and Giratina created matter and antimatter. Arceus created the elements that make up Pokémon types and Unova created the strengths, weaknesses, and balance among those elements. And they existed peacefully for a long time.
Until Giratina came to the others bearing a new creation, the Pokémon he called Darkrai. The others were angered by this, seeing it as a disruption to the balance they had created. In turn, Giratina became angry at them as it was very proud of its new creation. Harsh words were exchanged and the Arceus exiled Giratina to another dimension, which became Giratina's Distortion World. However, Darkrai was permitted to stay, as it had no choice in its own creation.
It was decided that the remaining four would each create their own being as well as create one together. Arceus made Mew and shared its power over all the elements, allowing Mew to use every possible technique. Dialga created Celebi and granted it the power to move through time while Palkia made Jirachi with the power to bend space. Unova created Shaymin and gave it the gift of harmony. Finally, together they made Victini and embodied it with the thrill of their victory.
This was how the first gods came to be.
*There is much debate on how the egg was created, if it was created, and who could've created it.
**The dragon that later split into Reshiram and Zekrom. It is usually unnamed but for simplicity's sake, I chose to name it after the region where it is best known.
