In the Bell CHSH experiment, why are Alice and Bob not allowed to pre-arrage their measurements? From Nielsen and Chuang, Chapter 2:

Imagine we perform the following experiment, illustrated in Figure 2.4. Charlie prepares
two particles. It doesn’t matter how he prepares the particles, just that he is capable
of repeating the experimental procedure which he uses. Once he has performed the preparation,
he sends one particle to Alice, and the second particle to Bob.
Once Alice receives her particle, she performs a measurement on it.
Imagine that she has available two different measurement apparatuses,
so she could choose to do one of two different measurements. These
measurements are of physical properties which we shall label PQ and
PR, respectively. Alice doesn’t know in advance which measurement she
will choose to perform. Rather, when she receives the particle she
flips a coin or uses some other random method to decide which
measurement to perform.


In testing the Bell CHSH inequalities, Alice and Bob randomly choose their measurements, and later they compare their data. Say Alice measures $\hat Q$ and $\hat R$ and Bob measures $\hat S$ and $\hat T$. Then, while comparing their data, they will look for instances where, say, Alice measured $\hat Q$ and Bob measured $\hat S$. They will multiply the outcomes of measuring of $\hat Q$ and $\hat S$ and take the average to get $ \langle \hat Q \hat R \rangle$. My question is: Why is it necessary that Alice and Bob choose their measurements randomly at each instance? Why can't they prearrange what are they going to measure? Does it make a difference?
(For example, for the first 100 measurements, Alice will measure $\hat Q$ and Bob will measure $\hat S$ and so on.)
 A: If Alice and Bob pre-arrange their measurements, somebody might attempt to argue that the act of pre-arrangement somehow affects the states of the particles.  Therefore when Alice and Bob make one pair of measurements, they are measuring particles in State A and when they make another, they are measuring particles in State B.
But the whole point is to test what happens when Alice and Bob make measurements on particles in one particular state.  Thus prearrangment would undermine the point of the experiment.
Admittedly, it seems very unlikely that pre-arranging your measurements could affect the states of the particles.  It seems astronomically more unlikely that pre-arranging your measurements could affect the states of the particles in just such a way that the outcomes of those experiments coincide exactly with the predictions of quantum mechanics.  But these unlikely explanations have in fact been proposed, so we want our experiment to be able to rule them out.
(Now of course someone might argue that the effects of Alice and Bob's random choices affect the states of the particles.  But, if you set the experiment up correctly, the choices are made at a time and place where they can't affect the states of both particles without information traveling faster than light.  Of course someone might now try to argue that information does travel faster than light.  At some point, we just need to stop worrying about this person and carry out our experiment.)
A: The description given in the question, in which each set of measurements settings are chosen randomly and independently, represents a relevant experimental situation, but it is not the most general way of talking about the CHSH inequality.
When thinking more generally about strategies that Alice and Bob might have, a common approach is to frame the setup as a CHSH game, in which Alice and Bob are working together to coordinate their measurement outcomes. More specifically, the typical setup is that they are each given a random bit (C1 and C2) by Charlie, and attempt to make their measurements results add up (mod 2) to (C1 xor C2).
In the usual setup for this game, Alice and Bob are separated and unable to communicate once they are actually performing the measurements, but they are able to communicate beforehand to develop a strategy, just as you've suggested. A simple form of this strategy is a deterministic strategy in which they pre-arrange the list of measurements that they will perform, again as you've suggested.
Regardless of the strategy that they choose, it can be proven that if they can only develop a plan beforehand that involves classical information, the bound on winning this game is 75%. However, if they are also allowed to entangle a pair of particles, then each bring one of the particles with them and perform measurements on it, they can exceed that bound. The strategy in this case involves using C1 and C2 to pick a measurement basis, then each measuring their qubit in that basis and reporting the results- in other words, exactly the setup that Nielsen and Chuang have focused on.
So, within the generalization of this game, the answers to your questions are:

Why is it necessary that Alice and Bob choose their measurements randomly at each instance? Why can't they prearrange what are they going to measure?

It's not, and they can!

Does it make a difference?

It does! It results in a less successful strategy that the quantum strategy, which is based on CHSH violation.
