Apart from the fairly obvious that it's also in the school's interest to get a child that was so close to the expected standard that it was down to getting 24 marks instead of 25 to a 5 (and seeing as one mark more would have had a 5 at GCSE as the minimum standard?
The process of groupings - and, as I said, they are not necessarily grouped in high/mid/low, it is often high/others/others or all/all/need TA support for some children/finds a large class difficult or allocating a dyslexia specialist - is something that takes extended planning.
The sort of things that are taken into account include assessment data from Y7, behaviour, KS2 data, CAT4 data, SEND, physical access, the number of TAs available, external tutoring or internal intervention support and their availability, how the timetable bands, blocks and clusters are set and how this cascades to the individual classes.
The En block will usually determine the groupings for similar subjects such as Drama, History & RE, sometimes MFL (but not always when there are two languages on offer), the Ma block at KS3 determines Science, IT & often Geography, then there are other blocks from which the PSHE, PE, Art, Food, Music and other classes are derived from.
You also have to take into account working patterns of staff, classroom maximum sizes, access requirements, equipment, physical location (to avoid having 340 of 1600 kids having to sprint from one end of the site to the other and up and down 5 flights of stairs during lesson changeovers whilst staff have to ping pong across the site in the opposite direction), particular specialisms and every pastoral requirement - there could be students who must not be in classes together, ones that need additional EAL support who are going to be helped more by being in a class with an EAL specialist to work with them (or will have a separate reallocation), part time/dual registered students who need to be able to access more than just English and Maths because they do that at their Hospital School, ensuring that what's offered is financially viable and doesn't mean you need to hire 3 new specialists on the first day of term, etc.
And then you repeat this process for the other 4 years (including sorting the options on the basis of preferences, reserves, ability, staffing, kids not responding, parents putting down Music and Dance and Dance as the reserve when you can't offer both as they are in the same band, parents disagreeing with their child's choice, etc) and two for 6th form. And then create the allocation exports, populate the fields and import them into the MIS (whilst also building the Pastoral Structure and determining whether a straight promotion into the next year is appropriate with a small number of exceptions or manually populating the structure for each of 1600 students).
Chuck in the MIS upgrades, all the other tasks required and it's a massive, massive task made harder by conspiracy theories and people misinterpreting standardised naming conventions and carefully considered decisions made with the interests of the child and their education foremost as 'My child is in the bottom set, they've already been written off/schools are bad'.