Spin statistics from the fundamental group of $SO(D)$
I studied algebraic topology from a mathematical point of view, so I can only try to explain the physical interpretation.
Beginning with the mathematics. The fundamental group associated with a pointed topological space is a set of equivalence classes of closed loops (under homotopy). But what does this mean? Let's start with basics.
A topological space $X$ is a general mathematical structure that is equipped with the notion of continuity and convergence (and etc.).
A pointed topological space is just the old topological space $X$, now equipped with a chosen point $a\in X$. One write this as $\left(X,a\right)$.
Why do we need a pointed topological space? Because then we can look on loops starting and ending at $a$. Those are continuous functions $\gamma :[0,1]\rightarrow X$ with $\gamma(0)=\gamma(1)=a$.
Those loops are interesting, because you can connect them one after another
$$(\gamma_{1}\ast\gamma_{2})(t)=\left\{\begin{matrix}\gamma_{1}(2t) & 0\leq t\leq\frac{1}{2}\\ \gamma_{2}(2t-1) & \frac{1}{2}< t\leq 1\end{matrix}\right.$$
and you can find their inverse (caution! this is incorrect, see below)
$$\gamma^{-1}(t)=\gamma(1-t)$$
You also have an identity element
$${\rm id}(t)=a$$
Therefore, you have here (almost) a group structure. For this to be a group, you can't really look at all the loops as different - you must consider two loops $\gamma_{1}$ and $\gamma_{2}$ to be the same, if you can deform $\gamma_{1}$ into $\gamma_{2}$ continuously. This is known as an homotopy. A great illustration of this is available in this Wikipedia page. I attach it also here
Mathematicians call this kind of "considering two objects to be the same" by the name equivalence relation, and this results in equivalence classes. Let's now denote by $[\gamma_{1}]$ all the loops that are equivalent to $\gamma_{1}$ under the homotopy relation. The set of all those loops
$$\pi_{1}(X,a)=\left\{[\gamma]|\gamma : [0,1]\rightarrow X,\: \gamma(0)=\gamma(1)=a\right\}$$
is called the fundamental group. Now returning to the inverse of a loop, try to think why
$$\gamma^{-1}\ast\gamma\neq{\rm id}$$
but in fact
$$[\gamma^{-1}]\ast[\gamma]=[{\rm id}]$$
Some examples
Let $X=\mathbb{R}^3$, i.e. the 3D space, and choose $a=0$ to be the origin. You can imagine that you can shrink every loop in $\mathbb{R}^{3}$ to a point, so all the loops are equivalent. This means that $\pi_{1}(\mathbb{R}^3,0)=\{{\rm id}\}$ is trivial.
Let $X=S^{1}$, the unit circle, and choose $a=(1,0)$. Note that every loop is characterized by how many times it circles the origin. That's an integer known as the winding number. So for instance, you have a loop that circles the origin once counter-clockwise ($=1$) and you have a loop that circles the origin twice, but clockwise ($=-2$) and so on. Therefore $\pi_{1}(S^{1},(1,0))=\mathbb{Z}$.
More relevant examples
Note that ${\rm SO}(1)=\{1\}$, so of course $\pi_{1}({\rm SO}(1))=\{{\rm id}\}$ is trivial.
For ${\rm SO}(2)$, you can argue that it is the same as $S^{1}$, in the sense that rotations in 2D are equivalent to $e^{i\theta}$, which form the unit circle. Thus $\pi_{1}({\rm SO}(2))=\mathbb{Z}$.
For ${\rm SO}(3)$, every rotation can be achieved by giving the axis of rotation, with is a point on the sphere $S^{2}$, and the rotation angle, which is in $S^{1}$. Note, however, that $(\boldsymbol{n},\theta)\sim(-\boldsymbol{n},-\theta)$ are equivalent rotations. This turns out to be equivalent to something known as the real projective space ${\rm RP}^{3}$, which has $\pi_{1}({\rm SO}(3))=\pi_{1}({\rm RP}^{3})=\mathbb{Z}_2$.
Now to the physics! What does the physics care about loops in ${\rm SO}(D)$? Let $t$ denote the time. How can we describe the exchange of two particles? The answer is by a curve $\gamma : [0,1]\rightarrow {\rm SO}(D)$ that describes the rotation of the two particles in the center-of-mass frame. This is a loop, because a full rotation of $2\pi$ is equivalent to doing nothing. Therefore, the number of topologically distinct loops is in fact the number of the different statistics possible. See also the following beautiful illustration taken from this Wikipedia page.
Anticlockwise rotation $\qquad\qquad\qquad$ Clockwise rotation
To quote the caption of this figure from Wikipedia
Exchange of two particles in $2 + 1$ spacetime by rotation. The rotations are inequivalent, since one cannot be deformed into the other (without the worldlines leaving the plane, an impossibility in $2D$ space).
The answer by @eranreches was posted before I posted this one. I have only one thing to add here, namely a different way of deducing that the fundamental group of $SO(D)$ has exactly two elements when $D\geq 3$. The approach used here is also connected to physics in an interesting way, because it relies on properties of the covering group of $SO(D)$, which describes how spinors transform. (This answer doesn't use spinors, but it does use the covering group.)
Throughout this answer, $D$ is assumed to be $D\geq 3$.
Loosely speaking, the fundamental group of a manifold $M$ is the set of continuous maps from the circle $S^1$ into $M$, modulo continuous deformations, equipped with a group structure as explained in detail by eranreches. Saying that the fundamental group of $SO(D)$ has exactly two elements is the same as saying that every loop in $SO(D)$ can be continuously deformed into either of two representative loops, and that these two representative loops cannot be continuously deformed into each other. In the usual representation of $SO(D)$ by matrices of size $D\times D$, we can take these two representative loops to be $$ L_1: e^{i\theta}\rightarrow \text{identity matrix} $$ and $$ L_2: e^{i\theta}\rightarrow \text{Rotation through angle $\theta$ in the $x$-$y$ plane}. $$ Here, $e^{i\theta}$ denotes an element of the circle $S^1$, parameterized by $0\leq\theta< 2\pi$. The map $L_1$ sends every point of $S^1$ to the same point of $SO(D)$, namely to the identity matrix. Both maps describe closed loops, because they both start ($\theta=0$) and end ($\theta=2\pi$) at the identity matrix in $SO(D)$.
First Claim: Every loop in $SO(D)$ can be continuously deformed to either $L_1$ or $L_2$.
Second Claim: $L_2$ cannot be continuously deformed to $L_1$.
Together, these two claims imply that the fundamental group of $SO(D)$ has exactly two elements. (Recall that $D\geq 3$ throughout this answer.) To deduce both of these claims, consider the covering group Spin($D$) of $SO(D)$. A way to construct this covering group is outlined in another post:
- What is the relationship between the Lorentz group and the CL(1,3) algebra?.
The important facts here are:
The covering is two-to-one. Given a faithful matrix representation of Spin($D$), the elements $\pm I$ in Spin($D$) both correspond to $I$ in $SO(D)$, where $I$ denotes the respective identity matrices.
Every loop in $\text{Spin}(D)$ can be continuously deformed to a point. In other words, $\text{Spin}(D)$ is simply connected.
Because of the two-to-one relationship of $\text{Spin}(D)$ to $SO(D)$, any closed loop in $SO(D)$ corresponds to either
Case A: A closed loop in $\text{Spin}(D)$; in other words, a path from $g$ to $g$ in $\text{Spin}(D)$. The map $L_1$ obviously has this form.
Case B: A path from $g$ to $-g$ in $\text{Spin}(D)$. The map $L_2$ has this form, as shown in the post cited above.
Here, $g$ denotes some matrix in the given faithful matrix representation of $\text{Spin}(D)$. The fact that Spin($D$) is simply connected immediately establishes the First Claim, so the fundamental group of $SO(D)$ cannot have any more than two elements. (By the way, if $D=2$, then the argument fails because the simply-connected covering group of $SO(2)$ is not a two-to-one covering.)
To establish the Second Claim, we need to show that Case B cannot be continuously deformed to Case A. This follows from the fact that the matrix $g$ in Spin($D$) cannot be the zero matrix, so the endpoints of the path in Case B must remain distinct from each other in Spin($D$).
Altogether, this shows that the fundamental group of $SO(D)$ has exactly two elements for every $D\geq 3$. The key to the argument is that $SO(D)$ has a two-to-one covering that is simply connected. A way of constructing this covering explicitly is described in the post cited above.