When I worked in business, managers--not the people they supervised--decided who would work together on a project. This made sense, since they were in the best position to objectively determine which staff members would provide the right combination of skill, teamwork, and other qualities to ensure a successful project.
The same goes for the classroom where teachers are in the best position to ensure all students are set up for success when they work in small groups. That's why it's better for you to assign students to groups than let students choose groups themselves--even in homogeneous classes, since you never want to risk some kids being more or less sought after by their classmates than others.
Setting students up for success also means you must assign them to groups strategically rather than randomly (e.g., having students count off by fives, and forming groups by their numbers). Start by identifying the factors for which you want to ensure balance, then divide students into groups accordingly. If, for example, peer tutoring is a purpose of your groups, be sure each group has at least one "go-to" person in it, with other students reflecting a range of academic needs. Other possible factors include gender, race, ethnicity, attendance (if you teach at a school with high truancy rates, as I did), and behavior.
Speaking of behavior, some teachers--including me early on--think it's better to isolate all the "bad" kids in one group rather than assign them to different groups, where they might drag the rest of the class down. But until you understand why kids are misbehaving, it's hard to know how they're going to act from one situation to the next. And since many students misbehave because they want attention or don't understand something, being in a group with conscientious classmates is often just what they need--a chance for them to rise up rather than drag others down.
Image by Cteconsulting, provided by Dreamstime license
Join my mailing list for announcements about webinars and the work I do to improve teaching and learning.