Rare candies cannot be bought in any of the Pokémon games, but Generation III introduced a way to gather as many as you need using the Pickup ability. This method relies on probability, so it can take hours of grinding.
Pick up a Pickup
The first thing you need is to have a Pokémon with the Pickup ability in your party. In Pokémon Ruby, only six Pokémon can have Pickup: Meowth, Aipom, Teddiursa, Phanpy, Zigzagoon and Linoone.
Pick a fight
Make sure that your Pokémon with Pickup is not holding any items, then go around battling other Pokémon. After every fight, there is a 10 percent chance that your Pokémon will pick up an item and another 10 percent chance that the item will be a Rare Candy. The Pokémon with Pickup doesn't need to fight to use its ability after a battle.
Every time your Pokémon picks up an item, put it away and keep looking for battles. Continue this process until you gather 99 Rare Candies.