The Cave of Origin can be accessed from Sootopolis City, and in Ruby and Sapphire you can catch a legendary pokémon there.
You can encounter pokémon in the cave. In the entrance hall, you can encounter Zubat and Golbat. In the dark rooms of the cave, you can encounter Zubat and Golbat, as well as Sableye in Sapphire and Emerald, and Mawile in Ruby.
Explore the Cave
In the first room of the cave, go north and enter the cave door.
The cave is dark, so be sure to teach Flash to one of your pokémon if you haven't already. You can use HM05 to teach Flash.
In the first dark room of the cave, go clockwise to find a ladder going down. In the next room, go counterclockwise. In the next room, go counterclockwise again, and in the next room, go clockwise. In Ruby and Sapphire, be sure to get the HM07 Waterfall that is there.
Legendary Pokémon's Room
After that, you will find the room of the Legendary Pokémon. In Emerald, you will find Wallace here. When he asks where Rayquaza is, say Sky Pillar.
In Emerald, Go to Sky Pillar
To reach the Sky Pillar, go south from Mossdeep City until you can't go any farther south, then go west until you reach Route 131. In the north middle of the route, there is a cave. Go in. Go to the top of Sky Pillar and watch the scene, then go back to Sootopolis City. Watch the scene, then find Steven, Archie, Maxie, and Wallace in front of the Gym. Talk to Wallace to get HM07 Waterfall. Then go into the Sootopolis Gym to challenge the Gym Leader.
In Ruby and Sapphire, Catch the Legendary Pokémon
Make sure you have prepared to catch the legendary. Save the game before starting the battle with the legendary, and make sure to read the Catch Groudon in Ruby and Kyogre in Sapphire page for tips on how to prepare.
Leave the Cave and Explore Sootopolis
After you catch the legendary, go outside using an Escape Rope, or just walk out. You can get TM31 Brick Break from a Black Belt in a house in the northwestern part of town, you can get a Wailmer Doll from a girl in a house on the east side of town, and you can get berries from Kiri, who in the southwest of town. You can get berries from her every day.
When you're ready, you should go to the Sootopolis Gym to get the eighth gym badge.