The basic idea is that the order of the repeating elements does not matter. So there will be fewer different permutations when elements repeat. So how many fewer?
Well, look at it this way. Any subset of elements creates a permutation within a permutation.
For instance, if we look at two elements within a permutation, A and B, they can either go A B or B A. Now if we make them both A, there is only one permutation A A. So any permutation that includes this repeating element will only have half the different permutations that it would if the repeating element were two different elements. So to find the actual number of different permutations, we would divide by two to account for the fact that either of the two orders of these elements is the same.
For example, where ordinarily a permutation of six elements used six times creates 6! different lineups, if two of the elements are the same, then all the permutations where one of those repeated elements comes before the other are the same as those where that element comes after the other. So there are only half the number of different permutations and the calculation becomes 6!/2.
If there are more than two elements that are the same, we need to figure out how many permutations within the permutation are actually the same. This is pretty simple. Just figure out how many permutations of the repeating elements there would be if the repeating elements were actually different. So if there is an element that shows up three times, that element would perm 3! = 6, but actually all six are the same. So in a permutation with three same elements we divide the basic permutation by 3! to get the actual number of different lineups. For example, in a permutation of 8 elements used 8 times, the formula would be 8!, but if three of the elements are the same, then 3! permutations within the permutations are the same. So we need to divide, 8!/3!, to get the actual number of different permutations.
This can obviously be applied to account for any number of repeating elements, and of there are multiple repeating elements, you just do it for each set.
So in a permutation of 8 elements, where two are the same as each other and another three are the same as each other, you start with the 8!. Then divide to account for the permutations within the permutation that are actually all the same. So it's 8!/2!3!.