The ideals of $\mathbb{Z}_n$ are, first of all, additive subgroups of $\mathbb{Z}_n$. These we know to all have the form $\langle d\rangle$, where $d$ divides $n$. But, as we know, the set $\langle d\rangle$ is the ideal generated by $d$. So we have just proven that
the ideals in $\mathbb{Z}_n$ are precisely the sets of the form $\langle d\rangle$ where $d$ divides $n$.
Since we are interested in maximal ideals, and this concept is defined in terms of containment
of ideals in one another, we now need to determine when we can have $\langle d_1\rangle\subset \langle d_2\rangle$. This is the case if and only if $d_1 \in \langle d_2\rangle$.
Here is the main result that you are seeking for: An ideal $I$ in $\mathbb{Z}_n$ is maximal if and only if
$I = \langle p \rangle$ where $p$ is a prime dividing $n$.