How the first Pokemon came to be :
Basically Arceus came out of an egg and created Palkia and Dialga.
In a vortex of complete chaos and nothingness, a single Egg comes into
being, which then hatches into Arceus, the first Pokémon in existence.
Arceus then creates Dialga, Palkia, and Giratina, giving them power
over time,space, respectively. Giratina, as punishment
for its destructive nature, is sent by Arceus to live in
the Distortion World. Dialga and Palkia then succeed in creating the
universe and Pokémon world and retreat into their
owndimensions afterwards, with a point of access being at the
ancient Spear Pillar in Sinnoh.
Then Arceus create the Lake Trio Azelf, Uxie and Mespirit.
Arceus creates Uxie, Mesprit, and Azelf, giving knowledge, emotion, and willpower to all living things that come into existence in the Pokémon world. The three dive into caves at the bottom of Lake Verity, Lake Valor, and Lake Acuity in Sinnoh, giving them the name "lake guardians
Kyogre is formed by the pressure underwater and Groudon is formed by the Magma and Rocks. Likewise, Rayquazza is formed by the minerals in the Ozone Layer.
Then the famous battle of Water Vs Land begins. Which is sorted out by Rayquazza
>Kyogre is formed by the pressure in the deep sea trenches, Groudon is formed deep inside the Earth, likely from hardened magma and earth, and Rayquaza is formed by the minerals of the ozone layer. Rayquaza proceeds to fly around in the ozone layer, occasionally coming to rest at Sky Pillar.Kyogre and Groudon then proceed to fill the sea and create land, respectively. A chance meeting turns the two into rivals, and a conflict for dominance over the Pokémon world begins. This battle continues until Rayquaza quells it, causing Kyogre and Groudon to retreat to special caverns, where they restuntil the events of Generation III many years later. The Red and Blue Orbs are created to prevent the reawakening of Kyogre and Groudon, and are left at Mt. Pyre for safekeeping.
Source : This has Everything