Example 5 Find all pairs of positive integers $(a, b)$ such that $\frac{a^{2}}{2 a b^{2}-b^{3}+1}$ is a positive integer.
(44th IMO)
When $b=1$, by the condition, $a$ is an even number.
When $b>1$, let $\frac{a^{2}}{2 a b^{2}-b^{3}+1}=k$.
Then the quadratic equation in $a$
$$
a^{2}-2 k b^{2} a+k\left(b^{3}-1\right)=0
$$

has positive integer solutions.
Thus, the discriminant of the equation in $a$ is a perfect square, i.e.,
$$
\Delta=4 k^{2} b^{4}-4 k\left(b^{3}-1\right)
$$

is a perfect square.
Notice that, when $b \geqslant 2$, we have
$$
\begin{array}{l}
\left(2 k b^{2}-b-1\right)^{2}-\Delta \\
=4 k b^{2}+4 k-2 b-1 \\
>0, \\
\left(2 k b^{2}-b+1\right)^{2}-\Delta \\
=4 k b^{2}-4 k-(b-1)^{2} \\
=4 k\left(b^{2}-1\right)-(b-1)^{2} \\
>(4 k-1)\left(b^{2}-1\right) \\
>0 .
\end{array}
$$

Thus, equation (2) holds.
Using the fact that $\Delta$ is a perfect square and equation (2), we have
$$
\begin{array}{l}
\Delta=4 k^{2} b^{4}-4 k\left(b^{3}-1\right)=\left(2 k b^{2}-b\right)^{2} \\
\Rightarrow 4 k=b^{2}
\end{array}
$$
$\Rightarrow b$ is an even number.
Let $b=2 l$. Then $k=l^{2}$.
Using equation (2), we can find $a=l$ or $a=8 l^{4}-l$.
Direct verification shows that $(l, 2 l)$ and $\left(8 l^{4}-l, 2 l\right)$ satisfy the conditions.

In summary, the pairs $(a, b)=(l, 2 l)$ or $\left(8 l^{4}-l, 2 l\right)\left(l \in \mathbf{Z}_{+}\right)$ satisfy the conditions.