The argument for Bell's inequality seems pretty straight-forward to me. Well, it's straight-forward in hindsight, anyway.
Following the Wikipedia article
https://en.wikipedia.org/wiki/Bell's_theorem,
Let
[itex]\mathcal{A} = A(a, \lambda)[/itex],
[itex]\mathcal{A}' = A(a', \lambda)[/itex],
[itex]\mathcal{B} = B(b, \lambda)[/itex],
[itex]\mathcal{B}' = B(b', \lambda)[/itex].
Now, define the quantity:
[itex]\mathcal{C} = \mathcal{A} \mathcal{B} +\mathcal{A} \mathcal{B}' +\mathcal{A}' \mathcal{B} -\mathcal{A}' \mathcal{B}[/itex]
We can rearrange this to:
[itex]\mathcal{C} = \mathcal{A}(\mathcal{B} + \mathcal{B}') + \mathcal{A'}(\mathcal{B} - \mathcal{B}')[/itex]
Since the function [itex]B[/itex] returns [itex]\pm 1[/itex], then either [itex]\mathcal{B}' = \mathcal{B}[/itex] or [itex]\mathcal{B}' = - \mathcal{B}[/itex].
If [itex]\mathcal{B}' = \mathcal{B}[/itex], then [itex]\mathcal{B} + \mathcal{B}' = \pm 2[/itex] and [itex]\mathcal{B} - \mathcal{B}' = 0[/itex]. So [itex]\mathcal{C} = \mathcal{A}(\pm 2) = \pm 2[/itex]. (Because [itex]\mathcal{A} = \pm 1[/itex].)
If [itex]\mathcal{B}' = -\mathcal{B}[/itex],then [itex]\mathcal{B} + \mathcal{B}' = 0[/itex] and [itex]\mathcal{B} - \mathcal{B}' = \pm 2[/itex]. So [itex]\mathcal{C} = \mathcal{A}'(\pm 2) = \pm 2[/itex]. (Because [itex]\mathcal{A}' = \pm 1[/itex].)
So for every possible value of [itex]a, b, a', b', \lambda[/itex], it's the case that [itex]\mathcal{C} = \pm 2[/itex]. Then when you average [itex]\mathcal{C}[/itex] over all possible values of [itex]\lambda[/itex], you can't possibly get a result that is greater than 2 or less than -2. So we have:
[itex]-2 \leq \int P(\lambda) \mathcal{C}(a,b,a',b',\lambda) \leq 2[/itex]
Expanding the definition of [itex]\mathcal{C}[/itex], we get:
[itex]-2 \leq \int P(\lambda) [ A(a,\lambda) B(b, \lambda) + A(a,\lambda) B(b', \lambda) + A(a', \lambda) B(b, \lambda) - A(a',\lambda) B(b',\lambda) ] \leq 2[/itex]
In terms of [itex]E(a,b)[/itex], this means:
[itex]-2 \leq (E(a,b) + E(a, b') + E(a', b) - E(a',b')) \leq 2[/itex]