Example 3 Find the value of $\sum_{k=1}^{\frac{n(n+1)}{2}}\left[\frac{-1+\sqrt{1+8 k}}{2}\right]$.

Translate the above text into English, please retain the original text's line breaks and format, and output the translation result directly.
Consider $f(x)=\frac{x(x+1)}{2}:[1, n] \rightarrow \left[1, \frac{n(n+1)}{2}\right]$
then $f^{-1}(x)=\frac{-1+\sqrt{1+8 x}}{2}$.
Consider the integer points within the rectangular region $x=1, x=n$, $y=1, y=\frac{n(n+1)}{2}$,
as shown in Figure 1.
It is easy to see that the number of integer points within the rectangle (including the boundary) is $\frac{n^{2}(n+1)}{2}$.
In region I, the number of integer points is
$$
\sum_{k=1}^{n}\left[\frac{n(n+1)}{2}\right] \text {; }
$$

In region II, the number of integer points is
$$
\sum_{k=1}^{\frac{n(n+1)}{2}}\left[\frac{-1+\sqrt{1+8 k}}{2}\right] \text {; }
$$

In the rectangular region, there are exactly $n$ integer points on the curve. By the principle of inclusion-exclusion, we have
$$
\begin{array}{l}
\sum_{k=1}^{\frac{n(n+1)}{2}}\left[\frac{-1+\sqrt{1+8 k}}{2}\right]+\sum_{k=1}^{n}\left[\frac{n(n+1)}{2}\right]-n \\
=\frac{n^{2}(n+1)}{2} .
\end{array}
$$

Solving for $S(n)=\sum_{k=1}^{\frac{n(n+1)}{2}}\left[\frac{-1+\sqrt{1+8 k}}{2}\right]$
$$
=\frac{n\left(n^{2}+1\right)}{3} \text {. }
$$