After you make it through the Seafloor Cavern and defeat the Team Aqua/Magma Leader at the end, you have to follow the awakened legendary pokémon to Sootopolis City.
Enter the City
To reach Sootopolis City, you have to travel to Route 126, which you can reach by going south from Route 124 or west from Route 127. When you get to Route 126, go to the south part of the area and use Dive, then go into the underwater cave entrance at the south end of the rocks in the center. From there, press B to go to the surface.
Meet Steven
There is water at the south end of Sootopolis City. There is a PokéMart northwest of the water, the Gym in the north part of the water, and the Pokémon Center to the northeast of the water. Go to the area near the PokéMart. Instead of going to the PokéMart, take the path to the right of the PokéMart and go north. As you go along this path, you will meet Steven. He takes you to the Cave of Origin, and if you are playing Ruby or Sapphire, you also meet the Gym Leader, Wallace.
In Ruby and Sapphire, Prepare to Catch the Legendary
Soon, you will find yourself face-to-face with a legendary pokémon, and you will have the opportunity to catch it. It can be very hard to catch. Read How to Catch Groudon in Ruby and Kyogre in Sapphire to learn how to prepare.
Teach a Pokémon Flash
The cave that you are about to go into is dark, so you will need to bring a pokémon that knows Flash if you want to be able to see where you are going. Flash is an HM move, so you can teach it to any number of pokémon. You can even teach it to Shedinja, but you might want to teach it to a different pokémon. There are many pokémon that can learn the move (too many to list), so just boot up the HM and check if anyone in your party is able to learn it.
Go into the Cave
When you are finished preparing, go into the Cave of Origin.