This page explains how to prepare for the battle with Groudon in Ruby and Kyogre in Sapphire, to help give you the best chance of success.
When Can You Catch Groudon/Kyogre
You can catch Groudon/Kyogre if you have defeated the leaders of Mossdeep Gym and defeated the Team Aqua/Magma leader in the Seafloor Cavern. After that, go to Sootopolis City and enter the Cave of Origin and find the legendary on the lowest floor.
Prepare to Catch the Legendary
The legendary pokémon will be at level 45. It can be very hard to catch. It has a very low catch rate, which means that all types of pokéballs (except for the Master Ball) have a low chance of working. Most of the time, the legendary pokémon will escape from the ball and you will have to throw another, and keep throwing more until you are lucky and the ball works.
You could use the Master Ball if you really want to, but there will be even better pokémon to try to catch later in the game, so you might want to save the Master Ball for later.
You can increase the chance of catching the legendary pokémon if you reduce its HP as much as possible, and inflict Sleep, Freeze, Poison, Paralysis, or Burn.
If you make the legendary faint, you won't get another chance to catch it! Be sure to save right before the battle, then if you don't catch it, turn off the game and turn it back on and try again.
Get Timer Balls and Ultra Balls/Net Balls
Timer Balls have the best chance to catch the legendary pokémon, but only if 30 turns have passed in battle. Before that many turns have passed, if you are playing Sapphire, Net Balls have the best chance of catching Kyogre. Otherwise, use Ultra Balls on Groudon until 30 turns have passed, then switch to Timer Balls. Each turn begins when your "Fight/Bag/Pokémon/Run" menu appears. It's OK if you lose count. Just start using Timer Balls if you think a lot of turns have passed.
You can buy Net Balls in Mossdeep City, you can get Timer Balls in Rustboro City (only if you have received a Repeat Ball from the Devon employee in Route 116), and you can get Ultra Balls in Fortree, Lilycove, Mossdeep, and Sootopolis Cities.
Get Healing Items
It's a good idea to get plenty of Revives and Hyper Potions and other healing items, because trying to catch the legendary could take a long time, and you wouldn't want all of your pokémon to get knocked out before you can catch the legendary.
If you need more money with which to buy balls and healing items, you can get more money by battling Interviewer Gabby and Ty repeatedly. You can fight Gabby and Ty as many times as you want to, making them a source of infinite money.
To make double the money that you win after battling them, give the Amulet Coin to one of the pokémon who participate in the battle. You can get the Amulet Coin from your Mom in Littleroot Town if you haven't already.
Gabby and Ty appear in Route 111 (east of Lavaridge Town, south of the desert), Route 118 (east of Mauville City, east of the water), and Route 120 (east of Fortree City, northeast corner of the route). If you check one of those locations and don't find them, try checking the other locations. They travel from location to location in that order: Lavaridge, Mauville, Fortree, Lavaridge, Mauville, Fortree, and so on.
They always do a double battle using Whismur/Loudred/Exploud and Magnemite/Magneton. The first time you battle them, their pokémon are level 19 in Ruby/Sapphire and level 17 in Emerald. They go up in level each time until you have battled them five times. After that, their pokémon will always be level 39.
Get a Pokémon that Knows False Swipe
Pokémon become easier to catch the lower their HP is. It's ideal if you can get the pokémon's HP down to 1. There is a move called False Swipe that you can use to do that. False Swipe does a normal amount of damage, but it won't make the pokémon's HP go any lower than 1.
However, there aren't very many pokémon in Ruby and Sapphire who know False Swipe. If you can trade with FireRed or LeafGreen, you can get Farfetch'd, Cubone, or Scyther, but this might not be practical. If you chose Treecko as your starter, it will learn False Swipe at level 59 (or 53 if you prevent Grovyle from evolving), but probably your starter is not near that level, so it would take too long. There is also Zangoose in Ruby, but it doesn't learn False Swipe until level 55.
Possibly the best option is to get a Nincada in Route 116, which is east of Rustboro City, then evolve the Nincada (raise it to level 20) while there is an empty slot in your party. When the Nincada evolves into Ninjask at level 20, you will also receive a Shedinja in the empty slot in your party (but if you don't have an empty slot, you won't get Shedinja). Shedinja only has 1 HP, no matter how much you level it up, but Shedinja has the rare ability Wonder Guard, which makes it immune to any attack that isn't supereffective. This means that Shedinja can only be knocked out by Flying, Rock, Ghost, Fire, and Dark moves.
Kyogre won't have any moves of that type, but Groudon uses Fire Blast. Fortunately, Groudon can only use Fire Blast five times before running out of PP for that move, so you can still use Shedinja, as long as you are careful or bring plenty of Revives. You can even teach Shedinja the move Spite, which lowers the PP of the move that was just used on you, and you can teach Shedinja Protect by buying the TM17 in the Lilycove Department Store (third floor). Use Protect to avoid Fire Blast, then use Spite to lower Groudon's PP for that move. But be aware that if Shedinja has lower speed than Groudon, you can't use this strategy because Groudon will use Fire Blast before Shedinja can use Spite.
Either way, Shedinja can learn Spite at level 25, and if you missed it and want to try that strategy, just take a Heart Scale to the Move Relearner in the northwest house of Fallarbor Town. You can find Heart Scales hidden in the beaches of Route 115, Route 104, Route 105, and Lilycove City. You can get also Heart Scales by catching Luvdisc in Route 128 (Good Rod or better) or Route 129 (Super Rod). Put a pokémon with the CompoundEyes ability in your first slot to increase the chance that the Luvdisc will be holding an item.
Bring a Pokémon that Knows a Sleep Move
Pokémon are easier to catch if they have a status ailment. Sleep and Freeze are the best status ailments for catching pokémon because they increase the catch rate the most. You could also inflict Poison or Burn, but these don't increase the catch rate as much, and you have the risk that the pokémon will faint if you don't catch it quickly. You can also Paralyze a pokémon, but this only increases the chance as much as Poison or Burn would.
There are many pokémon that know moves that inflict Sleep status. One option is to catch a Relicanth in the underwater area just outside of Sootopolis. Relicanth knows Yawn, but Relicanth is rare in this area, and if you use it against Groudon, be aware that Relicanth is weak to Groudon's Earthquake move. If you do want to try catching Relicanth, try bringing a pokémon that knows Sweet Scent, then in the first slot in your party put a pokémon with the Run Away ability, such as Poochyena, so you can repeatedly start battles until you encounter Relicanth.
You can also find Swablu in Routes 114 and 115. It can learn Sing. You also have a small chance of finding Chimecho on top of Mt. Pyre. It can learn Yawn.
Go to the Cave of Origin
When you're ready to try catching the legendary, go to the bottom floor of the Cave of Origin, save the game, then walk down below the legendary to start the battle.