I would think that, besides it being a wonderful, charming and funny character song for Herr Schultz, its placement there contrasts greatly with all the nastiness that Ernst and some of the others bring later to that scene. It would probably make the situation even more dramatic.