Example 9 Let $k \geqslant 2$ be a fixed positive integer, and $k$ positive integers $a_{1}, a_{2}, \cdots, a_{k}$ such that $n=\frac{\left(a_{1}+a_{2}+\cdots+a_{k}\right)^{2}}{a_{1} a_{2} \cdots a_{k}}$ is a positive integer. Find the maximum value of $n$.


When $a_{1}=a_{2}=\cdots=a_{k}=1$, $n=k^{2}$. Below is the proof that $k^{2}$ is the maximum value.
Suppose $k$ positive integers $a_{1}, a_{2}, \cdots, a_{k}$ make $n=\frac{\left(a_{1}+a_{2}+\cdots+a_{k}\right)^{2}}{a_{1} a_{2} \cdots a_{k}}$ a positive integer. By the principle of the smallest number, we can assume $a_{1}, a_{2}, \cdots, a_{k}$ make $n=\frac{\left(a_{1}+a_{2}+\cdots+a_{k}\right)^{2}}{a_{1} a_{2} \cdots a_{k}}$ hold, and make $a_{1}+a_{2}+\cdots+a_{k}$ the smallest value of $k$ positive integers.

From $n=\frac{\left(a_{1}+a_{2}+\cdots+a_{k}\right)^{2}}{a_{1} a_{2} \cdots a_{k}} \Leftrightarrow a_{1}^{2}+\left(2 a_{2}+2 a_{3}+\cdots+2 a_{k}-n a_{2} a_{3} \cdots a_{n}\right) a_{1}+\left(a_{2}+a_{3}+\cdots\right.$ $\left.+a_{k}\right)^{2}=0$. Consider the above equation as a quadratic equation in $a_{1}$, and let the other root be $a_{1}^{\prime}$, then $a_{1}+a_{1}^{\prime}=n a_{2} a_{3} \cdots a_{n}-2 a_{2}-2 a_{3}-$ $\cdots-2 a_{k}, a_{1} a_{1}^{\prime}=\left(a_{2}+a_{3}+\cdots+a_{k}\right)^{2}$. Since $a_{1}$ is a positive integer, $a_{1}^{\prime}$ is also a positive integer. Therefore, $a_{1}^{\prime}, a_{2}, \cdots$, $a_{k}$ also satisfy $n=\frac{\left(a_{1}^{\prime}+a_{2}+\cdots+a_{k}\right)^{2}}{a_{1}^{\prime} a_{2} \cdots a_{k}}$. By definition, we know $a_{1} \leqslant a_{1}^{\prime}=\frac{\left(a_{2}+a_{3}+\cdots+a_{k}\right)^{2}}{a_{1}}$, hence $a_{1} \leqslant a_{2}+$ $a_{3}+\cdots+a_{k}$.
By symmetry, without loss of generality, assume $a_{1} \geqslant a_{2} \geqslant \cdots \geqslant a_{k}$.
Let $f(x)=\frac{\left(x+a_{2}+\cdots+a_{k}\right)^{2}}{x a_{2} \cdots a_{k}}=\frac{x+\frac{\left(a_{2}+\cdots+a_{k}\right)^{2}}{x}+2\left(a_{2}+\cdots+a_{k}\right)}{a_{2} \cdots a_{k}}$
Then it is easy to know that $f(x)$ is a decreasing function on the interval $\left(0, a_{2}+\cdots+a_{k}\right]$, and $0<a_{2} \leqslant a_{1} \leqslant a_{2}+\cdots+a_{k}$, so
$$
\begin{aligned}
n & =f\left(a_{1}\right) \leqslant f\left(a_{2}\right)=\frac{\left(a_{2}+a_{2}+a_{3}+\cdots+a_{k}\right)^{2}}{a_{2} a_{2} a_{3} \cdots a_{k}} \\
& \leqslant \frac{\left(a_{2}+a_{2}+a_{3}+\cdots+a_{k}\right)^{2}}{a_{2}^{2}} \leqslant \frac{\left(a_{2}+a_{2}+\cdots+a_{2}\right)^{2}}{a_{2}^{2}}=k^{2} .
\end{aligned}
$$

Therefore, the maximum value of $n$ is $k^{2}$.