I think it is a wonderful idea so long as the pet is age-appropriate for the class. For example, hamsters are not suitable for younger children in my opinion. Maybe if it were one or two children, but not an entire classroom. Guinea pigs are especially not suitable for younger children because if dropped even from a few feet they could break their back which will lead to paralysis or even death.

So as long as the teacher is RESPONSIBLE, the children understand the animal and is quiet and patient around them, and it is age-appropriate for the group, an animal in the classroom can be a WONDERFUL learning experience for children of any age