I've done a bit of research on this myself.
There's another object called
GroupMember which acts as a junction object between the User and the Group itself which contains the following fields:
Running a query like the following:
SELECT GroupId,Id,SystemModstamp,UserOrGroupId FROM GroupMember WHERE GroupId = '00GD0000004HMw3MAG'
Will return a list of people in that particular group. The field
UserOrGroupId holds the ID of the users within that particular group.
So what you would need to do is create a new GroupMember object, assigning the users to that particular group.
You'll first need to get the Id of the Group you want to assign people to and query that, then where you create. Something like this will work:
group = [SELECT Id FROM Group WHERE Name = 'Support Team 1'].Id;
user = [SELECT Id FROM User WHERE Name = 'John Smith' LIMIT 1].Id;
GroupMember gm = new GroupMember(
GroupId = group;
UserOrGroupId = user;