In Pokémon R/B/Y and Green there is a slight bug in the formulae which decides which move the enemy Pokémon will use.
The game would ensure that if the enemy Pokémon has a move which is super effective or regular effective it would use that move over a 'not very effective move' with super effective moves being those that are the 'top-priority' ones. However this also meant that if the opponent's only regularly effective or higher effective move was a status or stat-altering move the opponent would be forced into using it.
This is a problem notably with psychic type moves such as Barrier, Light Screen and Agility (which was a psychic type move until Generation III) for example a Rapidash's high special attack would make it relatively easy to defeat a Golbat of the same level with fire blast; however if that same Rapidash also had agility it would never use fire blast until Agility's PP was 0. As a result that Golbat would have plenty of time to defeat that Rapidash.
This glitch was fixed in later generations of the Pokémon games especially in comparison to Generation IV where the opponent's AI has been greatly improved.
- Thread on Glitch City Laboratories Forums on the Move AI glitch