A Rare Candy gives you just enough EXP to get your Pokemon to the next level. If it needs 1 EXP to get to the next level, then it will give your Pokemon 1 EXP. If it needs 5000, it will give it 5000. This is why it's recommended to use Rare Candies at higher levels, when it's harder to level up. Also note that Rare Candies don't give EVs, so your Pokemon may be weaker than normal if you use them.
Hope I helped!