Mesomeric Effect and its Strength
Some background knowledge
You need to be aware of electronegativities, assignement of s and p character, relation of structure to the donating or accepting nature of the substituent, and most importantly, the overlap efficiency of the donor and acceptor positions (roughly estimated by overlap integral , although for the sake of this discussion, most of the mathematical rigor is not required)
I will be comparing most of the order for the +M effect, and provide some hints for the -M effect.
Group 1: from $\ce{O-}$ to $\ce{OCOR}$
This group of substituents consists of two kinds of donor atoms from the 2nd period, namely $\ce{O}$ and $\ce{N}$. As they are from the same period as $\ce{C}$ , therefore, overlap efficiency will be maximum in this case, for 2p-2p overlap.

Recall that p-p overlap&gt; s-p overlap&gt; s-s overlap as per overlap efficiency

Due to this reason, this group of substituents will have better +M effect as compared to the halogens, because as we move down the group 17, overlap efficiency for 2p-3p,2p-4p overlap and so on decreases.
However, a member of period 2 does exist among the halogens, namely $\ce{F}$ .But since it is more electronegative than both $\ce{O}$ and $\ce{N}$, it will again have lesser donating tendency as compared to this group.
Now, let's get down to the specific cases:
The group leader $\ce{O-}$ :
First,let us look at some enthalpy values:
$\ce{ O(g) + e^- -&gt; O^-(g) 1st EA = -142 kJ /mol }$  (1)
$\ce{ O^-(g) + e^- -&gt; O^2-(g) 2nd EA = +844 kJ /mol }$ (2)
As you can clearly see, adding an electron to $\ce{O-}$ ( or adding a second electron to $\ce{O}$) is an endothermic process, which means energy will have to be provided externally for pushing more electron density inside $\ce{O-}$.
That is pretty obvious as well, because you are forcing an electron into an already negative ion. It's not going to go in willingly! The second electron affinity of oxygen is particularly high because the electron is being forced into a small, very electron-dense space.[source]
Conversely, this means that the reverse reaction for (2) will be pretty favorable, in the sense that $\ce{O-}$ will quite readily give away electron density to a suitable acceptor atom,as is evident from the enthalpy values. Hence, $\ce{O-}$ leads the charge in terms of +M effect

It is to be kept in mind that the factor of compatibility of overlap still holds. Donation from $\ce{O-}$ to, say, $\ce{Si}$ will still not be as effective as that to $\ce{C}$

Subgroup 1:The curious case of $\ce{-NH2}$,$\ce{-NHR}$ and $\ce{-OR}$
First of all, since we have got neutral donor atoms in this subset, it stands to reason that simple electronegativity will be the major governing factor here to judge the overall donation tendency. Hence, both the $\ce{N}$ donor groups should be more donating than the $\ce{O}$ donor group.
The slightly peculiar judgement crops up when you are deciding between $\ce{-NH2}$ and $\ce{-NHR}$ . On a preliminary basis, you might say that since the $\ce{R}$ will most probably be exerting a strong +I effect ,and thereby the latter should have had more +M effect than the former.
But here's the catch: the electron density of the $\ce{N-R}$ bond will mostly shift towards N as compared to the $\ce{N-H}$ bond, but the donation to the benzene ring will ultimately take place by the $\ce{N}$ atom. And hence, it becomes important to look at what the donor nitrogens of these two groups have to say.
We are basically going to compare the bond angles of $\ce{H-N-H}$ and $\ce{H-N-R}$ .Due to the sterically bigger $\ce{R}$ group , the latter should be greater than the former. This means that the s-character will go up on the $\ce{N}$ atom of the latter, and this directly means that electronegativity for it will increase.

(Think of the various hybridization schemes, namely $\ce{sp}$ , $\ce{sp^2}$ and $\ce{sp^3}$, the percentage s character in each, the bond angles for each, and the electronegativity trend of $\ce{sp}$&gt;$\ce{sp^2}$&gt;$\ce{sp^3}$ )

Hence, donation power of $\ce{-NHR}$ should be less than $\ce{-NH2}$

A similar argument will also explain why the +M effect of $\ce{-OR}$ is less than $\ce{-OH}$

Subgroup 2: $\ce{-NHCOR}$ and $\ce{-OCOR}$
Both these group are analogous structurally, and that's the key to their relative comparison for our purpose. On a preliminary basis, we see that the number of highly electronegative atoms( that is, $\ce{O}$, $\ce{N}$ and $\ce{F}$) has increased in both these groups as compared to the previous members of this group. $\ce{-NHCOR}$ has an $\ce{O}$ and $\ce{N}$, while $\ce{-OCOR}$ has two oxygens. This immediately tend to make them less donating than the previous members of the group.
Another reason to see why they would be less donating is because of the distribution of partial charges in the resonance hybrid. The donor atom's lone pairs in both the cases are conjugating between a $\ce{C=O}$ group and the benzene ring. Since negative charge is more stable on $\ce{O}$ than on $\ce{C}$, the oxygen of the $\ce{C=O}$ will end up possessing much of the negative charge which would otherwise be available for donation to the ring.
In other words, we can say that the charge will be dispersed over a competing electron sink, namely, the $\ce{C=O}$ .Hence, their mesomeric effects will decrease considerably as compared to other members of the group.
As for their individual comparisons, you can easily judge that by the electronegativities of their individual donor atoms, $\ce{N}$ and $\ce{O}$
The phenyl group
Wikipedia says:

It is generally considered an inductively withdrawing group (-I), because of the higher electronegativity of sp2 carbon atoms, and a resonance donating group (+M), due to the ability of its π system to donate electron density when conjugation is possible.

Drawing from this, one can say that since the phenyl group is donating by using bond pair of electrons(namely, it's $\ce{C=C}$ π bonds) rather than lone pairs(unlike all the previous groups which were using lone pairs of $\ce{N}$ or $\ce{O}$) therefore it will have lesser donation tendency than the preceding members as lone pairs are generally more &quot;freely available&quot; for donation, being attracted by a single nucleus rather than bond pair of electrons which are held by two nuclei.
Still, as it is a donation from a $\ce{C}$ donor atom, it has better +M effect as compared to the halogens.
Comparison between $\ce{-Ph}$ and $\ce{-F}$ is a tough case, as it may seem that fluorine which is using it's lone pairs should have been a better donor than $\ce{-Ph}$. To this I would say that maybe since fluorine is the most electronegative element, it's electronegativity would dominate the donating tendency by the lone pairs(in technical terms, HOMO-LUMO gap would be more in case of F's non-bonded electrons than the $\ce{C=C}$ pi-bonded electrons)
But again, this reasoning would seem unsatisfactory.  Anyway,the mesomeric effect of the $\ce{-Ph}$ group usually holds little chemical interest. It mainly serves as a control, and we are much more interested in the effect of hetero atoms on the ring as compared to the effect of one benzene ring on another(in case of mesomeric effect)
Group 2:The halogens
I have already given enough idea about them above, more details can be found here
So there you have it. A similar idea can be applied for deducing the logic of the -M ordering as well.

Hints for -M effect

$\ce{-NO2}$ has 3 highly electronegative atoms, and an electron sink in the form of $\ce{-N=O}$, so it should lead the pack.

Just like the previous ordering, we are again interested in the characteristics of the acceptor atom here. While for +M effect, it increased with decrease in s-character(and hence electronegativity) on the donor atom, and more freely available electron density

-M effect will increase with increase in s-character(and hence electronegativity) of the acceptor atom. Since in your list, the remaining substituents are $\ce{C}$ acceptors, then the hybridization of $\ce{C}$ needs to be considered.
Accordingly, $\ce{-CN}$ should fall next with an $\ce{sp}$ hybridized $\ce{C}$

Now most of the items I can see on the list are substituents with $\ce{sp^2}$ carbons, having different combinations of $\ce{O}$ and $\ce{N}$ attached to the acceptor atom. Your job would now be to checking the varying extents of cross conjugation happening at the electron sink directly attached to the acceptor atom(and thereby comparing the electron accepting ability of the same) by looking at the electron donating abilities of the attached heteroatoms


You can ask for further clarification if these hints should not prove to be sufficient.