In the original Pokémon series, this could be used on a Pokémon to let it gain one level, but as the name suggests, it was very rare. In Pokémon Tower Defense, though, Team Rocket tries to steal it, and in many levels you will have to defend this. You will have to defend piles of varying sizes, usually between 3 and 20. In the Pewter Gym level's cutscene, Brock uses it to power up his Onix. It appears in a lot of the levels in Pokémon Tower Defense, so in this game, it is not really that rare.
Sam had stated that in a future update, rare candies will be able to be obtained so that they can be used on your own Pokémon, but this never made the final update.
In PTD2 you can purchase Rare Candies in 1v1 mode.