Firstly, let's begin with the general case of $|\psi\rangle = a|0\rangle+b|1\rangle$. The normalisation condition that $|a|^2 + |b|^2 = a^a + b^b = 1$. That may have been your mistake, but I will proceed as though you knew that and simply mistyped. First, we must recognise that $|\psi\rangle$, like all kets, has complex phase freedom - that is that on their own $|\psi\rangle$ and $e^{ix}|\psi\rangle$ for all $x\in R$ correspond to the exact same physical state (notice how both will have the same norm). This is not just a peculiarity of this system by the way, this is a feature of all quantum states. The original and the phase shifted version are only distinct when compared to other states, but if those other states are also shifted by the same phase then the distinction disappears again. If this is not familiar to you, then you need to study up on this because phase freedom is a core concept in quantum mechanics that you will need to master.
Having recognised this, we are therefore free to choose $a$ and $b$ such that $a$ is real - if $a$ were not real, we could just shift the phase of $|\psi\rangle$ so it was. 28
Using the polar representation of complex numbers, we can then just redefine our coefficients by $b\to e^{i\phi}b$ so $b$ is real and $\phi$ is its phase. You should recognise we have not made any restrictions here, we have just changed how we are describing things. We can restate our original restriction then by $|a|^2 + |e^{i\phi}b|^2 = a^2 + b^2 = 1$ where both $a$ and $b$ are real. Immediately looking at this you should be reminded of <PERSON>' theorem, which might remind you of trigonometry, and further you could notice how this related to the unit circle. Given that $-1 \leq a \leq 1$, we can represent it as $a =\cos(\frac{\theta}{2})$. One of the most important identities of trigonometry is that $\sin^2(x) + \cos^2(x) = 1$, which comes directly from <PERSON>' theorem. We can thus say that $b^2 = 1 - a^2 = 1 - \cos^2(\frac{\theta}{2}) = \sin^2(\frac{\theta}{2})$, thus $b = \pm \sin(\frac{\theta}{2})$. This final piece of sign ambiguity can then be removed by recognising that in the case where we have a negative sign, we can just perform a redefinition $\phi \to \phi + \pi$ without loss of generality which will then cancel the negative sign. 976