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:
This gives UserIds, and their Groups List:
where UserOrGroupId in (select id from user)
Now you need to combine these two datasets based on the Id.