Let $\omega_d(G)$ be the number of elements of order d in the finite group G. Let X be the collection of all finite groups G such that for every d, $\omega_d(H) = \omega_d(G) \mod |H|$ for every subgroup H ≤ G.
As jspecter's remarks, X is clearly closed under subgroups, so we may be interested in minimal non-X-groups, those groups which are not in X but every proper subgroup is in X.
Lemma: The cyclic group of order pq for distinct primes p, q is a minimal non-X-group.
Proof: It has p−1 elements of order p, but it cannot be the case that both p−1≡0 mod q and q−1≡0 mod p. $\square$
Lemma: A finite group with both a cyclic subgroup and an elementary abelian subgroup, both of order $p^2$, cannot be an X-group.
Proof: The number of elements of order p in the whole group must be equal to $p^2-1 \mod p^2$ due to the elementary abelian subgroup, but it must also be equal to $p-1 \mod p^2$ due to the cyclic subgroup. $\square$
Proposition: A finite abelian group is an X-group if and only if it is a cyclic p-group or an elementary abelian p-group for some prime p.
Proof: If the group is not a p-group, then the first lemma applies. If the group is not of exponent p, then it must be cyclic by the second lemma. $\square$
Proposition: A finite 2-group is an X-group if and only if it is cyclic, elementary abelian, or the quaternion group of order 8.
Proof: If the group has exponent 2, then it is elementary abelian. Otherwise it contains an element of order 4. By the second lemma it contains no elementary abelian subgroups of rank 2, and so it must be cyclic or generalized quaternion. However the generalized quaternion group of order 16 is a minimal non-X-group, and so the only possibility is Q8 which is easily checked to be an X-group, have 6 elements of order 4, which is 2 mod 4 and 0 mod 2. $\square$
The p-groups for odd p will defy such an explicit classification, since all groups of exponent p are X-groups. However, this is the only obstacle:
Proposition: A p-group for odd p is an X-group if and only if it is cyclic or of exponent p.
Proof: Again, unless it is exponent p it cannot have any elementary abelian subgroups of rank 2. In the odd p case, this leaves only the cyclic groups as candidates. $\square$.
Proposition: A nilpotent group is an X-group if and only if it is a cyclic p-group, a group of exponent p, or the quaternion group Q8.
Proof: A nilpotent X-group must be a p-group lest it contain a cyclic subgroup of order pq. $\square$
I will leave solvable groups open for now, but remark with jspecter that non-abelian groups of order pq and more generally cyclic groups of order $p^n$ acting faithfully and irreducibly on groups of order $q^m$ are X-groups, as they have $(p^d-p^{d-1})q^m$ elements of order $p^d$ which is 0 mod $q^m$ as it should be, and since $1 \equiv q^m \mod p^n$ in order for the action to exist, it is even equal to $p^d - p^{d-1}$ mod $p^d$ as it should be. Similarly, $q^m-1$ is equal to 0 mod $p^n$ and $q^d-1$ mod $q^d$, all as it should be.
Proposition: A finite non-abelian simple group is an X-group if and only if it is PSL(2,4) or PSL(2,8).
Proof: We have several convenient hypotheses available: the Sylow 2-subgroups are elementary abelian (cyclic and quaternion being ruled out by Glauberman's Z*-theorem), and so the group is either a $\operatorname{PSL}(2,2^n)$ or J1. Explicit calculation rules out J1, and confirms PSL(2,4) and PSL(2,8). For general $2^n$, our group contains cyclic groups of order $2^n+1$ and $2^n-1$, both of which must be prime powers. I believe the only solutions to this are $2^2\pm1=3,5$ and $2^3\pm1=7,9$, but I am not sure if this a well-known fact or an open problem in elementary number theory.
This can be extended to all almost simple groups by observing that S5 and PΓL(2,8) are not X-groups. The direct product of almost simple groups is never an X-group, since it contains a cyclic subgroup of order $2p$.
Best Answer
Note that $A_8$ consists of only even permutations and hence the maximum order of any element of $A_8$ can be $15$ which is a small number so it's not that hard to check for each number between $1$ and $15$ that whether there exists an element of that order or not. So for example for odd numbers between $1$ and $8$ $\exists$ an element of that order, just consider the element $(12345)$ for exmaple for $5$.
$\nexists$ any element of order $8$ because the only such element in $S_8$ is $(12345678)$ but it is not in $A_8$. The possibilities of an element of order 11 and 13 are easily ruled out. Now since the order of any two disjoint cycles is the $lcm$ of their orders hence the possibilities of $9,10,14$ is also ruled out. Finally for orders $12$ and $15$ consider the elements $(123456)(78)$ and $(12345)(678)$ respectively.