It's for niceness. For instance, if $f(x) = 1$, then all the $a_i$ and $b_i$ integrals turn out to be $0$, and you want to recover $c_0 = 1$. But it turns out that $\int_0^{2\pi} 1\,dt = 2\pi$ is too large, so you scale it back down.
Similarily, if $f(x) = \cos kx$, for some natural number $k>0$, then $a_k$ is the only integral that becomes non-zero, and we want to recover $a_k = 1$. However, it turns out that $\int_0^{2\pi}\cos kt\cdot \cos kt\,dt = \pi$, which is too large, so we need to scale it down. (And the argument for $b_k$ is exactly the same.)
Alternatively, we could do the definitions of $a_k, b_k$ and $c_0$ without the $\frac1{2\pi}$ and $\frac1\pi$ factors, but then we would have to make up for that someplace else, like with
$$f(x) = \frac{c_0}{2\pi} + \frac1\pi\sum_{n = 0}^\infty a_n\cos nx + b_n\sin nx$$
It's a matter of personal preference where you would best like to put these factors, but they must appear somewhere.