Example 3 Find all positive integers $n$, such that $\frac{n(n+1)}{2}-1$ is a prime number.

Find all positive integers $n$, such that $\frac{n(n+1)}{2}-1$ is a prime number.
Let $a_{n}=\frac{n(n+1)}{2}-1$, then $a_{1}=0$ is not a prime number, so we only need to discuss the case when $n>1$. We will use the fact that $n$ can only be of the form $4k$, $4k+1$, $4k+2$, or $4k+3$ and discuss each case separately.

When $n$ is of the form $4k+2$ or $4k+1$, $a_{n}$ is always even. For $a_{n}$ to be a prime number, it can only be
$$\frac{n(n+1)}{2}-1=2$$

Solving this, we get
$$n=2$$

When $n=4k$, we have
$$\begin{aligned}
a_{n} & =2k(4k+1)-1 \\
& =8k^2+2k-1 \\
& =(4k-1)(2k+1)
\end{aligned}$$

This is a composite number.
When $n=4k+3$, we have
$$\begin{aligned}
a_{n} & =2(k+1)(4k+3)-1 \\
& =8k^2+14k+5 \\
& =(4k+5)(2k+1)
\end{aligned}$$

Only when $k=0$, i.e., $n=3$, is $a_{n}$ a prime number.
Therefore, the values of $n$ that satisfy the condition are $n=2$ or $3$.
Explanation: Classifying $n$ is necessary both for eliminating the denominator and for preparing to factorize.