Bernard was Dewey's class hamster. When Dewey was put in charge of taking care of it, he used this as an opportunity to try and get a pet dog by showing how good he was with animals. However, he put the hamster in a hamster ball and freed it to save it from another student in his class whom he was worried would injure or kill him the next week.
As a recurring gag, Bernard can be seen running in the background of multiple episodes unnoticed by the characters.