Configure private / closed group access, membership and visibility gives details about setting up a group so that users can access it. (That topic needs to be renamed and/or linked to other howto topics so that it is more easily searchable.)
Site admins and group owners can invite users to Discourse and include a list of group names in the invite. Users will be automatically added to the groups when they accept the invitation. This topic gives more details: Configure how users can create and send invites for others to join your community.
Another way to add users to a group is to use the Data Explorer plugin to write a query that returns a list of usernames or email addresses of users who should be added to a group. The results of the query can be copied into the group’s Bulk Add to Group form.
Users can also be added to groups through the Discourse API.