Templates are sets of HTML, CSS, and JS code that can be used to create multiple messages. An example of a template would be an alert banner which could be used for different purposes depending on the situation.
Using a template lets you reuse a set of styles or JS functionality between messages without having to copy & paste them over.
A template can define fields (or variables) that each message can then fill. For example a banner template might define a title and a text field. You could then use the template to create multiple messages, each with their own title and text.
Templates can have variables in their HTML and CSS code. Adding variables in the CSS code lets you for example create different color variations of the same template.