Here, under the Section 'Example', the following function $$\sum_{n \geq 0}{\frac{2a_n}{3^{n+1}}}$$ is given as a homeomorphism between $2^{\mathbb{N}}$ and the Cantor Middle third set.
I don't see the motivation behind this function. Can anyone explain it?
One definition of the Cantor set is that it is that subset of $[0,1]$ consisting of all those numbers whose ternary expansion contains no $1$s (can you see why?). In other words, they contain only $0$s and $2$s. So we can identify an element of $2^\mathbb N$ with an element of the Cantor set by mapping $0$s to $0$s in the ternary expansion and $1$s to $2$s in the ternary expansion. For example:
$$ (0,0,1,1,0,1,1,0,0,0,1,1,1,0,1,\dots)\mapsto 0.002202200022202\dots_3 $$
where the expansion is in ternary. This is precisely the function that you have given. It turns out that it is a homeomorphism.