Im reading up on Fourier series and found out that its based on projecting a piecewise continuous function onto the function space defined by the orthonormal basis:
$\{\frac{1}{\sqrt{2}},\sin{x},\cos{x}, \sin{2x}, \cos{2x}...\}$
It makes sense that we can easily project a function onto this basis, but how can we assure that information about the function isn't lost in the process; i.e. how do we make sure that the Fourier series span all piecewise continuous functions.
If your original function $f$ is piecewise continuous on $[0,2\pi]$ for instance, then it is easy to check that it is square integrable on that interval: $$\int_0^{2\pi}|f(x)|^2 dx <+\infty$$ We say that $f\in L^2([0, 2\pi])$. Then it is a famous result that the Fourier functions form an orthonormal basis of that space. In particular, the Fourier functions span a set that is dense in the space of square integrable functions.
So no information is lost.
There are several proofs of it. For instance, on that interval, you can approximate piecewise continuous functions using continuous functions, and all continuous functions can be approximated using trigonometric polynomial (thus the Fourier basis). See the Stone-Weierstrass theorem for that, or properties of the Fejer kernel.
The intuition behind this is that continuous functions are smooth enough that you can represent them with a sum of oscillating functions (the Fourier basis), with higher and higher frequencies. If your function is continuous but not super smooth, you'll need high frequency Fourier functions to represent it. If the function is very smooth (e.g. infinitely differentiable), then you'll need a small set of Fourier functions in the sum, mostly for low frequencies.
For piecewise continuous functions, the points of discontinuity create a jump and the Fourier basis is not a very efficient representation. Typically, the Fourier coefficients will decay like $\mathcal O\left(\frac 1 n\right)$, so you'll need a lot of coefficients to obtain a good approximation of your function.