How to create a new Tag group and save it?
You were on the right track. To save things in Craft, you need to use the according service. In your case you need the tags service:
$tagGroup = new TagGroup();
$tagGroup-&gt;name = 'GroupName';
$tagGroup-&gt;handle = 'GroupHandle';
$isTagGroupSaved = Craft::$app-&gt;getTags()-&gt;saveTagGroup($tagGroup);

if(!$isTagGroupSaved) {
    // Inspect validation errors if saving the tag group failed
    var_dump($tagGroup-&gt;getErrors());
}