The periodic square wave $$ f(x) = \cases{ 1 \text{ if } 0 \le x \le \pi \\ 0 \text { if } -\pi \le x < 0} $$ seems easy enough to work with. Why transform it into a series of sines and cosines?
I'm writing up take-home bonus problems for my Calculus II class. I know one of my students is interested in Fourier series and it's relevant to many others, I'm sure, so one of the problems is a easy Fourier expansion of the square wave. I'd like to include in the introduction why someone might turn a seemingly-simple function like this into an infinite sum of trig functions.
From the applied side, one could say that the motivation lies in trying to solve some partial differential equations like diffusion equations or wave equations.
For example, the diffusion of heat along a rod can be modeled as $$u_t = c^2u_{xx} \quad (*)$$ where $u(x,t)$ is the temperature at position $x$ of the rod at time $t$. We are given the initial distribution of heat: that is, at $t=0$, $u(x,0) = f(x)$. We wish to find a solution to $(*)$.
A common way to solve this involves writing $u$ as a (Fourier) series. In particular, if $f(x)$ can be written as $\sum_{k=1}^\infty a_k \sin(kx)$, then one has that $$u(x,t) = \sum_{k=1}^\infty a_k\sin(kx)e^{-k^2t}$$ is indeed the solution to $(*)$. Notice that even when $f(x)$ is as simple as the one you've given, $(*)$ is still hard to solve without use to Fourier series.
(Disclaimer: of course, technically I should be careful about boundary conditions of the differential equations and about the convergence of the sequence. I vastly simplified stuff since we are only trying to have a motivation.)