Deriving the average number of inversions across all permutations
You can not go directly from one equation to the other; you need to add a whole proof which is separate from what I explain there. Hence my statement "it has been shown".

A boring proof using induction is here.

For a constructive proof, you can follow the idea from here:


Show that the maximum number of inversions is $\binom{n}{2}$.
Observe that every permutation and its reverse pair up: their respective
sets of inversions are complement to each other, so both together add $\binom{n}{2}$ inversions to the sum.
Since this pairing neatly and uniquely covers all permutations, we get that the total number of inversions across all permutations is $\frac{n!}{2} \cdot \binom{n}{2}$.


The claim follows immediately.