Literally, "a fun group" means a group of people who are enjoying themselves, talking and joking together. The noun "fun" is being used as an adjective, meaning "cheerful, happy, and merry."
The school principal is being ironic. Ironic is a form of sarcasm. It consists of saying the exact opposite of what you mean, in a tone of voice that makes it clear that you're mocking someone.
In the United States, the person who runs a school is called the "principal." I think the position is called "headmaster" in British usage.
Detention is a form of punishment for high school students who misbehave. It consists of keeping them after school for a period of time, usually about an hour, before letting them go home. They are being "detained." The noun form of "detained" is "detention;" they are "in detention." During that time they are being strictly monitored and aren't allowed to do anything except work quietly on schoolwork.
The principal could mean "you had your 'fun' earlier, now the fun is over," or he could mean "You all look sullen and unhappy..." or both at once.