[proofplan]
The periodicity condition lets us descend $f$ from the upper half-plane to a [holomorphic function](/page/Holomorphic%20Function) $F$ on the punctured unit disc via the coordinate $q=e^{2\pi i z}$. Holomorphicity at the cusp is precisely removability of the puncture at $q=0$. Once the puncture is filled, the ordinary power-series expansion of the holomorphic extension gives the desired $q$-expansion; conversely, a convergent [power series](/page/Power%20Series) with only nonnegative powers defines the required holomorphic extension at $0$. The cusp condition is then the statement that the extended value $F(0)$ is zero, which is exactly the constant coefficient $a_0$.
[/proofplan]
[step:Descend the periodic function to the punctured unit disc]
Let
\begin{align*}
\mathbb D^* := \{w \in \mathbb C : 0 < |w| < 1\}.
\end{align*}
The map
\begin{align*}
q: \mathbb H &\to \mathbb D^* \\
z &\mapsto e^{2\pi i z}
\end{align*}
is surjective. Indeed, if $w \in \mathbb D^*$, choose a complex logarithm $\ell \in \mathbb C$ satisfying $e^\ell=w$, and define
\begin{align*}
z := \frac{\ell}{2\pi i}.
\end{align*}
Since $|w|=e^{\operatorname{Re}(\ell)}<1$, we have $\operatorname{Re}(\ell)<0$, hence $\operatorname{Im}(z)>0$, so $z \in \mathbb H$ and $q(z)=w$.
Define
\begin{align*}
F: \mathbb D^* &\to \mathbb C \\
w &\mapsto f(z) \quad \text{for any } z \in \mathbb H \text{ with } q(z)=w.
\end{align*}
This definition is independent of the chosen $z$. If $z_1,z_2 \in \mathbb H$ and $q(z_1)=q(z_2)$, then
\begin{align*}
e^{2\pi i(z_1-z_2)}=1,
\end{align*}
so $z_1-z_2 \in \mathbb Z$. Since $f$ is $1$-periodic, $f(z_1)=f(z_2)$. Thus $F$ is well-defined and satisfies $F(q(z))=f(z)$ for every $z \in \mathbb H$.
The function $F$ is holomorphic on $\mathbb D^*$. For any $w_0 \in \mathbb D^*$, choose $z_0 \in \mathbb H$ with $q(z_0)=w_0$. On a sufficiently small disc $V \subset \mathbb D^*$ around $w_0$, choose a holomorphic logarithm
\begin{align*}
L: V &\to \mathbb C
\end{align*}
with $e^{L(w)}=w$. Then
\begin{align*}
\sigma: V &\to \mathbb H \\
w &\mapsto \frac{L(w)}{2\pi i}
\end{align*}
is holomorphic after choosing the branch with values near $z_0$, and $q(\sigma(w))=w$. On $V$ we have $F(w)=f(\sigma(w))$, so $F$ is holomorphic as a composition of holomorphic maps.
[/step]
[step:Derive the q-expansion from holomorphicity at the cusp]
Assume that $f$ is holomorphic at the cusp $\infty$. By definition, the function $F: \mathbb D^* \to \mathbb C$ extends to a holomorphic function
\begin{align*}
\widetilde F: \mathbb D &\to \mathbb C,
\end{align*}
where $\mathbb D := \{w \in \mathbb C : |w|<1\}$ and $\widetilde F|_{\mathbb D^*}=F$.
Since $\widetilde F$ is holomorphic on $\mathbb D$, it has a power-series expansion at $0$ with [radius of convergence](/theorems/273) at least $1$. Thus there exist complex numbers $(a_n)_{n=0}^{\infty}$ such that
\begin{align*}
\widetilde F(w)=\sum_{n=0}^{\infty}a_n w^n
\end{align*}
for every $w \in \mathbb D$. Restricting to $w=q(z)$ gives, for every $z \in \mathbb H$,
\begin{align*}
f(z)=F(q(z))=\widetilde F(q(z))=\sum_{n=0}^{\infty}a_n q(z)^n.
\end{align*}
Since $q(\mathbb H)=\mathbb D^*$, the same power series converges for every $w \in \mathbb C$ with $0<|w|<1$.
[/step]
[step:Use a convergent q-series to fill in the cusp]
Conversely, suppose there exists a sequence $(a_n)_{n=0}^{\infty}$ of complex numbers such that
\begin{align*}
f(z)=\sum_{n=0}^{\infty}a_n q(z)^n
\end{align*}
for every $z \in \mathbb H$, and such that the power series converges for every $w \in \mathbb C$ with $0<|w|<1$.
Define
\begin{align*}
\widetilde F: \mathbb D &\to \mathbb C \\
w &\mapsto \sum_{n=0}^{\infty}a_n w^n.
\end{align*}
Because the series is a power series with nonnegative powers and [radius of convergence](/theorems/265) at least $1$, $\widetilde F$ is holomorphic on $\mathbb D$. For $w \in \mathbb D^*$, choose $z \in \mathbb H$ with $q(z)=w$. Then
\begin{align*}
\widetilde F(w)=\sum_{n=0}^{\infty}a_n w^n
=\sum_{n=0}^{\infty}a_n q(z)^n
=f(z)
=F(w).
\end{align*}
Thus $\widetilde F|_{\mathbb D^*}=F$, so $F$ extends holomorphically to $0$. Hence $f$ is holomorphic at the cusp $\infty$.
[/step]
[step:Identify the vanishing condition with the constant coefficient]
Under the extension above, the value of $f$ at the cusp $\infty$ is defined to be
\begin{align*}
\widetilde F(0).
\end{align*}
For the power-series expansion
\begin{align*}
\widetilde F(w)=\sum_{n=0}^{\infty}a_n w^n,
\end{align*}
substituting $w=0$ gives
\begin{align*}
\widetilde F(0)=a_0.
\end{align*}
Therefore $f$ vanishes at the cusp $\infty$ if and only if $\widetilde F(0)=0$, which is equivalent to $a_0=0$.
[/step]