I think the claim goes back to the 1979 paper "Monstrous Moonshine" by Conway and Norton, where they discuss the "defining property of 24": If $n$ is a positive integer such that $xy \equiv 1$ mod $n$ implies $x \equiv y$, then $n|24$. This fact is used in Atkin's determination of the normalizer of $\Gamma_0(N)$ in $SL_2(\mathbb{R})$. The number 24 plays a special role here, in the sense that the normalizer is $\Gamma_0(n|h)+$, where:
- $h$ is the largest divisor of 24 such that $h^2|N$
- $n = N/h$
$\Gamma_0(n|h) = \left\{ \begin{pmatrix} a & b/h \\ cN & d \end{pmatrix} \mid a,b,c,d \in \mathbb{Z}, ad-bcn/h = 1 \right\}$. The notation is meant to suggest that the group is conjugate to $\Gamma_0(n/h)$, but contained in and contains $\Gamma_0(nh)$.- The $+$ means we adjoin all possible Atkin-Lehner involutions. If $n/h$ has $k$ prime factors, then this extends $\Gamma_0(n|h)$ by an elementary abelian 2-group of rank $k$.
The connection between your observation and moonshine does not seem particularly strong to me, but that may be because I was too young to have experienced firsthand the heady days of numerical exploration. It involves the normalizers of $\Gamma_0(N)$ in the following way: There is a graded representation $V^\natural = \bigoplus V^\natural_m$ of the monster, such that for each element $g$ of the monster, the McKay-Thompson series $T_g(\tau) = \sum_{m \geq -1} Tr(g|V^\natural_m)q^m$ is the $q$-expansion of a modular function invariant under some genus zero group $\Gamma$ that contains and normalizes some $\Gamma_0(N)$, and therefore lies in some $\Gamma_0(n|h)+$ , where $n = |g|$. This fact was essentially the main conjecture in the Conway-Norton paper, although the paper enhances this claim with an explicit list of the candidate functions and their invariance groups. My understanding of the solution process is:
- Atkin, Fong, and Smith gave a computational proof of existence (1980).
- Frenkel, Lepowsky, and Meurman constructed a candidate representation $V^\natural$ (1984), and showed that it had a vertex operator algebra structure (1988).
- Borcherds proved that the candidate representation was satisfactory (1992).
Wikipedia and sundry expository books by Gannon, du Sautoy, Ronan, and others can say more about the precise history than I can. I should mention that the number 24 is important as the central charge of $V^\natural$ in Borcherds's solution to the Monstrous Moonshine conjecture, but the paper does not make explicit use of the number 24 in the "group of units" role. One might reasonably argue (through a somewhat convoluted path) that these are the same 24, though.
There may be other connections, but I am unaware of them.

