It is never explained in the Pokemon world how one goes about becomming a Gym Leader, but it is told why the Gym Leaders exist. They are and extension of the Pokemon League and each hold their own badge, an insignia awarded to young trainers after successfully defeating each Gym Leader. Upon collecting all 8 badges of the given region, the trainer is then permitted to face against the Elite Four and the Champion, and if they win, they also receive the title of Pokemon Master. Each Badge has a special trait that also follows. They allow Pokemon up to a certain level to obey you and allow the use of Hidden Machines. This works well in the game mechanics but how about in the life of a trainer say in the anime or manga? Perhaps it is an unspoken law in the world of Pokemon or perhaps the badges do not have those special abilities in these versions.
Each Gym Leader is a master of a specific type of Pokemon and the badge usually reflects that type. Giovanni, as stated before, is the master of ground-type Pokemon and his badge is the coveted Earth Badge. This badge is based on the sacred Sakaki leaf and once obtained will allow all Pokemon to obey you and will gain you entry into the Pokemon League. It is never explained in the series but one could figure that each Gym Leader would get to pick which sort of badge they want and which type of Pokemon they fight with.
What sort of Gym Leader is Giovanni? It can be gathered that many trainers never make it to him and if they do, they rarely progress to the Pokemon League. Many trainers are struck with fear just entering the gym. Giovanni with his wit and power probably intimidates many young trainers. We can also conclude that it is rare for young trainers to obtain the Earth Badge. In the game, upon defeating Giovanni, he says:
"Ha! That was a truly intense fight! You have won! As proof, here is the Earth Badge! Having lost, I cannot face my underlings! Team Rocket is finished forever! I will dedicate my life to the study of Pokémon. Let us meet again someday! Farewell!"
Giovanni then disappears. It can also be said that he loses honorably. As a Gym Leader, however, I believe that they do not have a persuation between good or evil. Giovanni is a villain but as the Gym Leader is neutral and testing young trainers are what Gym Leaders do. They weed out the trainers who are too weak to progress to the league and Giovanni is a perfect candidate to do so.