Why is det used here instead of den? I thought that the gender of 'it' would have to match the gender of 'class'?
You'd use 'det'/'den' had the word already been introduced. 'det' and 'den' can only refer to something already stated, otherwise you'd use 'det'.
"Det er klassen. Den er liten." = "That/It is the class. It is small."
"Den er en liten klasse" = "That class is a small class."