This is the section of canon law having to do with baptismal sponsors:
SPONSORS
Can. 872 Insofar as possible, a person to be baptized is to be given a sponsor who assists an adult in Christian initiation or together with the parents presents an infant for baptism. A sponsor also helps the baptized person to lead a Christian life in keeping with baptism and to fulfill faithfully the obligations inherent in it.
Can. 873 There is to be only one male sponsor or one female sponsor or one of each.
Can. 874 §1. To be permitted to take on the function of sponsor a person must:
1/ be designated by the one to be baptized, by the parents or the person who takes their place, or in their absence by the pastor or minister and have the aptitude and intention of fulfilling this function;
2/ have completed the sixteenth year of age, unless the diocesan bishop has established another age, or the pastor or minister has granted an exception for a just cause;
3/ be a Catholic who has been confirmed and has already received the most holy sacrament of the Eucharist and who leads a life of faith in keeping with the function to be taken on;
4/ not be bound by any canonical penalty legitimately imposed or declared;
5/ not be the father or mother of the one to be baptized.
§2. A baptized person who belongs to a non-Catholic ecclesial community is not to participate except together with a Catholic sponsor and then only as a witness of the baptism.
If someone were to ask me, I’d say baptism classes were established because some bishops or parishes recognized that a good faith effort to establish that sponsors met the conditions of canon law and were well-informed of their duties required such a class. In other words, experience taught that it could not be assumed that the parents would choose candidates who were both eligible and aware of the duties of a Catholic godparent. Everyone has to go to the classes in order to avoid giving insult to those who absolutely do need the classes but won’t admit that they do.
Pastors generally have the latitude to use their own good judgment to deem a baptismal sponsor well-prepared without the classes. It is far easier to have a rule requiring classes and make exceptions to the requirement (by allowing some people to do less) than to make people who need more training to be the exceptional cases and telling them they have to do more than the typical amount. Some pastors find it reasonable to just ask everyone to go to the classes. It isn’t an onerous requirement.