Is there a SOQL query or a method to extract all users, their profiles and group membership from Salesforce?
There is no straight forward way to export all the info in one go. You can export Users, and their profile info in one query and users/group membership in another query, then join the info based on the User id.
This gives users and profile info:
select Id, Email, Name, Profile.Name from User
This gives UserIds, and their Groups List:
select UserOrGroupId, Group.Name from GroupMember where UserOrGroupId in (select id from user)
Now you need to combine these two datasets based on the Id.