There is a related question physics.stackexchange.com/q/75321 everything is answered in the second chapter of Weinberg's QFT. Unfortunately, Weinberg is confined to 4d, which is special and he is not a mathematician, hence there is no word highest weight there. If you need more general treatment please see pedagogical paper arxiv.org/abs/hep-th/0611263
To put it short, one has to know the representation theory of the symmetry group of a given space time and then try to realize them on the solution space of some P.D.E.. Apparently, P.D.E. must impose enough G-invariant conditions to project onto an irreducible representation. Transverse, traceless, symmetric and not forget $(\square-m^2)$. In fact, it need not be symmetric, it can be any irreducible tensor of the Lorentz algebra (symmetric and traceless is just the simplest type of irreducible tensor).
The harmonicity is needed since Fourier integral clearly shows that the representation is infinitely reducible unless $(\square-m^2)$ is imposed. Represent $\phi$ as $\int dp\, \psi(p) \exp ipx$ and perform Poincare transformations, you see that modes with different $p^2$ do not mix, which means that ϕ(x) is a continuum of representations, that's why we need to fix $p^2$ by imposing $(\square-m^2)$. Spin is just the highest weight of the Wigner's little group, $so(d−2)$ for massless fields and $so(d−1)$ for massive. $(s,0,...,0)$ is called a spin-s for brevity (in 4d there is just one weight). For example the spectrum of string theory is full of massive fields of any spin $(s1,s2,....)$. The harmonicity fixes the quadratic Casimir $P_\mu P^\mu$ of the Poincare algebra, as we want an irreducible representation the Casimir must be a fixed number.
The general theory goes as follows. Let us have some nice space-time with a lot of symmetries, Minkowski $ISO(d-1,1)/SO(d-1,1)$, de Sitter $SO(d,1)/SO(d-1,1)$ or anti-de Sitter $SO(d-1,2)/SO(d-1,1)$. One then is interested in unitary irreducible representations of the space-time symmetry group. These representations are characterized by some numbers, weights. We like highest-weight representations since the energy of a particle must be bounded from below (this is not possible in de Sitter, that's why people are still trying to understand what QFT in de Sitter is). The lowest energy is related to the mass of a particle. The rest of the weights are referred to as the spin of a particle. Then we would like to realize representations as solutions to certain P.D.E's. This is a different problem.
When the space-time has few symmetries or no symmetries at all (generic solution of Einstein equations) then we cannot say what spin or mass is. An exception is when the space-time has enough assymptotic symmetries, e.g. it is assymptotically flat. For example, we know that gravity linearized over the Minkowski space describes a massless spin-two field. When gravity is linearized over a generic background it still describes two (in $4d$) propagating degrees of freedom, but there are no symmetries to say that they correspond to something with spin two.
As for the string theory, you can simply look in any textbook. People discuss the spectrum of excitations and find there a massless spin-two, which is a graviton and infinitely many other fields, mostly massive. These massive fields can be found in any $(s_1,s_2,...,s_3)$ of $so(25)$ if we talk about bosonic strings, which are in $26d$, hence we deal with $iso(25,1)$ and the Wigner's little group for massive fields is $so(25)$.