Yes. That shifts der Klasse to a dative object meaning “to the class,” rather than a locational phrase.
• Ich erklärte der Klasse den Zweck… = “I explained the purpose to the class.”
• Ich erklärte den Zweck … vor der Klasse. = “I explained the purpose in front of the class,” emphasizing the physical setting.
German typically follows the Time–Manner–Place (TMP) order for adverbs. With a normal subject-verb start, a time adverbial like gestern comes right after the verb:
Subject (Ich) – Verb (erklärte) – Time (gestern) – Object (den Zweck…) – Place (vor der Klasse).
If you begin with gestern, you must still keep the verb in second position:
Gestern erklärte ich ….
You could, but it slightly alters the nuance:
• in der Klasse = “inside the classroom,” focusing on location.
• vor der Klasse = “in front of the class,” emphasizing that you addressed the group (e.g. giving a presentation).