It works exactly as the documentation lays out.
Optional. If set to true, the subject, plain text, and HTML text bodies of the email are treated as template data.
It basically allows you to create your own template from Apex
. Here's a demonstration of how it would work:
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setTreatBodiesAsTemplate(true);
// now merge fields will be treated as templates
email.setSubject('Hi {!User.CommunityNickname}');
email.setPlainTextBody('Sending a test to {!User.Name}');
email.setHtmlBody('<p>Sending a test to {!User.Name}</p>');
// the above values will be merged in once the email is sent
email.setTargetObjectId(UserInfo.getUserId());
email.setSaveAsActivity(false);
// you cannot save emails as an activity when the target is a User
Messaging.sendEmail(new List<Messaging.Email> { email });