Why does gimbal lock occur “in two circles”?

Solution 1:

As explained in this MathOverflow answer, there is a way to realise any closed orientable connected 3-manifold (in particular, $T^3$) as a branched covering of $S^3$. By projecting further to $\mathbb{RP}^3\cong\mathrm{SO}(3)$, one can therefore reduce the singular set to finitely many points.

However, this completely destroys one useful property of the Euler angle parametrisation, namely the fact that it is a group homomorphism when restricted to the standard ”coordinate“ 1-parameter subgroups of $T^3$. If one adds this restriction, I believe, one wouldn't be able to do better than with some 1-dimensional singular set; your computation essentially shows this for the case where the 1-parameter subgroups in $\mathrm{SO}(3)$ obtained this way are the standard generators.