Why is boson spin number related to attraction and repulsion? The accepted answer to this question says

Since the electroweak interaction is mediated by spin 1 bosons, it is the case that "like (charge) repels like and opposites attract".

Another answer comments:

The Higgs is spin - 0 (scalar field) and the graviton is spin - 2; attractive.

From this other question

a force mediated by a spin-0 scalar is always attractive.

So what's going on here? Why does the spin of the boson determine whether the force is universally attractive or follows the opposites-attract-and-like-repels-like pattern?
What would it look like for a spin-3 or spin-4 boson, if such a particle existed?
 A: Here's a schematic approach that highlights
where the sign of the force comes from,
at least in the spin-0 and spin-1 cases.
I don't know how to generalize it to higher-spin cases.
The approach assumes
that the Hamiltonian is quadratic
in the force-mediating boson field, so it
excludes QCD, whose higher-than-quadratic
terms cannot be neglected.
The approach uses a semi-classical approximation
in which the force-mediating boson
field is treated as a classical field,
again excluding QCD.
The one thing that the approach handles carefully
is the signs.
Consider two models.
One involves matter particles
interacting with a spin 0 (scalar) field $\phi$.
The other involves matter particles
interacting with a spin 1 abelian gauge field $A_\mu$.
The Lagrangians are
$$
  L =  \frac{\big(\dot\phi(x)\big)^2
    -\big(\nabla\phi(x)\big)^2}{2} - \phi(x) J(x)
    + \cdots
\tag{1}
$$
and
$$
    L = -\frac{1}{4}F_{\mu\nu}F^{\mu\nu}-A_\mu J^\mu+\cdots
\tag{2}
$$
with $F_{\mu\nu}=\partial_\mu A_\nu-\partial_\nu A_\mu$.
The operators $J$ and
$J^\mu$ are constructed from the matter field,
which I'll be more explicit about later.
The dots denote the kinetic terms
for the matter field.
The signs of the coupling terms $\phi J$ and $A_\mu J^\mu$
are not important: they can be chosen as desired by choosing
the sign-convention for the boson fields.
However,
the signs of the kinetic terms for $\phi$ and $A_\mu$ are
important:
they must be chosen so that the energy (the Hamiltonian) has
a finite lower bound.
This positive-energy requirement is the key
to explaining the connection between
the spin of the boson and the sign of the force
that it mediates.
Now consider situations in which the motion of the
matter and the time-dependence
of the boson fields are both negligible.
This simplifies
things in a few ways: (1) we can neglect
all terms involving time-derivatives,
(2) the temporal component $J^0$ is the only
significant component of the current,
and (3) with the help of a gauge-fixing choice,
the temporal component $A_0$
can be regarded as the only significant component
of the gauge field (as in electrostatics).
After these simplifications, the Hamiltonians reduce to
$$
  H =  \int d^3x\ \left(\frac{
    \big(\nabla\phi(x)\big)^2}{2} + \phi(x) J(x)
    + \cdots\right)
\tag{3}
$$
and
$$
  H =  \int d^3x\ \left(\frac{
    \big(\nabla A_0(x)\big)^2}{2} + A_0(x) J^0(x)
    + \cdots\right),
\tag{4}
$$
and the equations of motion for the boson fields
reduce to
$$
    \nabla^2\phi(x)=J(x)
    \hskip2cm
    -\nabla^2 A_0(x) = J^0(x).
\tag{5}
$$
Notice the opposite signs here.  Using the same
Green function $G(x-y)$ in both cases,
we can express the boson fields in terms of $J$ and $J^0$
like this:
$$
    \phi(x) = \int dy\ G(x-y)J(y)
    \hskip2cm
    A_0(x) = -\int dy\ G(x-y)J^0(y).
\tag{6}
$$
Substitute these back into the
Hamiltonian to see that the energy in the
spin 0 case is
$$
    H = \frac{1}{2}\int d^3x\ J(x)G(x-y)J(y) + \cdots
\tag{7}
$$
and that the energy in the
spin 1 case is
$$
    H = \frac{-1}{2}\int d^3x\ J^0(x)G(x-y)J^0(y) + \cdots
\tag{8}
$$
Again, notice the opposite signs.
Given an explicit expression
for the Green function,
we can determine the sign of the force
between particles of matter
by looking at how the energy varies with the
distance $|x-y|$.
Or, since we already know that like charges repel each other
in electrodynamics,
we can just compare the spin-0 and spin-1 results
to conclude that like charges must attract each other
in the spin-0 case.
What about opposite charges? If the matter field is a spin-1/2 fermion field, then we have
$$
    J\propto \overline{\psi}\psi = \psi^\dagger\gamma^0\psi
    \hskip2cm
    J^0\propto \overline{\psi}\gamma^0\psi = \psi^\dagger\psi.
\tag{9}
$$
If we define
$$
    \psi_\pm = \frac{1\pm\gamma^0}{2}\psi,
\tag{10}
$$
then
$$
    J\propto\psi^\dagger_+\psi_+ - \psi^\dagger_-\psi_-
    \hskip2cm
    J^0\propto\psi^\dagger_+\psi_+ + \psi^\dagger_-\psi_-.
\tag{11}
$$
Use the fact that fermion fields are anticommutative to get
$$
    J\propto\psi^\dagger_+\psi_+ + \psi_-\psi^\dagger_-
    \hskip2cm
    J^0\propto\psi^\dagger_+\psi_+ -\psi_- \psi^\dagger_-.
\tag{12}
$$
I didn't write the kinetic terms for the matter field,
but thanks to the positive-energy requirement,
we can (schematically!) identify the first term
in each of these expressions as the charge density
of the particle, and the second term as the charge
density of the corresponding antiparticle.
Now, substitute these expressions for $J$ and $J^0$
back into the previous expressions for the energy.
The fact that both terms in $J$ have the same sign
means that in the spin 0 case, the sign of the force
is the same for particle-particle, particle-antiparticle,
and antiparticle-antiparticle.
The fact that the two terms in $J^0$ have the opposite signs
means that in the spin 1 case, the sign of the force
for particle-antiparticle is opposite the sign
of the force for particle-particle or antiparticle-antiparticle.
Granted this was all very schematic and specific
to the spin-0 and spin-1 cases, but maybe it at least
captures part of the answer to your question.
A: For bi-linear interactions it is simply a fact that the algebra of Dirac $\gamma$ matrices leads to uniform attraction for spin 0 boson exchange and attraction/repulsion for unlike/like charges for spin 1 boson exchanges.  The nonlinear structure of QCD may alter this relationship for gluon exchanges as pointed out in a comment by @annav.  I don't remember the details of the derivations from my graduate school days 50 years ago, but I do remember that the final result was clear and convincing.
