Answer edited for clarity. Originally, although the Math was okay, my presentation of the ideas needed improvement.
I think Inclusion Exclusion works here. See this article for an
introduction to Inclusion-Exclusion.
Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula.
Actually, this application of the Inclusion-Exclusion theory is somewhat off the beaten track.
Let $~S~$ denote the collection of all permutations of $~\{~x_1, ~x_2, ~x_3, \cdots, ~x_n ~\},~$ without any regard for whether outlawed 2-cycles are present.
Let $~c~$ denote $~\displaystyle \left\lfloor \frac{n}{2}\right\rfloor.$
That is, $~c~$ is the largest integer $~\leq \dfrac{n}{2}.$
So, any outlawed permutation will have exactly $~j~$ outlawed 2-cycles, where $~j~$ is some element in $~\{1,2,3,\cdots,c\}.$
Let $~T_0~$ denote the number of elements in the set $~S.$
So, $~T_0 = n!.$
For $~r \in \{ ~1, ~2, ~\cdots, ~c ~\},~$
I will define $~T_r~$ in the following convoluted manner:
I will identify all of the ways that there are of selecting exactly $~r~$ distinct pairings from the
set $~\{x_1,x_2,\cdots,x_n\}.$
For each such selection of $~r~$ pairings, I will enumerate all of the (outlawed permutations) that specifically have those $~r~$ (outlawed) 2-cycles, and might or might not have other outlawed 2-cycles.
That is, for each such designation of $~r~$ pairings, the remaining $~(n-2r)~$ elements can be permuted in $~(n-2r)!~$ ways, and some of these permutations may create other (outlawed) 2-cycles from the other $~(n-2r)~$ elements.
I will then express the final computation as
$$\sum_{r=0}^c (-1)^r T_r. \tag1 $$
So, the problem reduces to computing each of
$~T_1, ~T_2, ~\cdots, ~T_c.$
This convoluted algorithm deserves explanation.
As proven in the second link, at the start of this answer:
$$\forall ~j \in \Bbb{Z^+}, ~\sum_{r=1}^j (-1)^r \binom{j}{r} = -1.$$
To consider why the formula in (1) above works, take any outlawed permutation and assume that this permutation has exactly $~j~$ outlawed 2-cycles, where $~j \in \{1,2,\cdots,c\}.$
For each $~r~ \in \{1,2,\cdots,j\},~$ the specific outlawed permutation will occur $~\displaystyle \binom{j}{r}~$ times in the enumeration of $~T_r.$
For each $~r~ \in \{j+1, j+2,\cdots,c\},~$ the specific outlawed permutation will not occur at all in the enumeration of $~T_r.$
So, the overall effect of applying the formula in (1) above will be that the specific outlawed enumeration will be deducted exactly one time, from the $~T_0 = n!~$ enumeration.
Further, this will apply to any individual outlawed permutation.
$\underline{\text{Computation of} ~T_1}$
There are $~\displaystyle \binom{n}{2}$ ways of selecting two elements from $\{~x_1,x_2,\cdots,x_n\}$ to form the outlawed 2-cycle.
So,
$$T_1 = \binom{n}{2} \times (n-2)!.$$
$\underline{\text{Computation of} ~T_2}$
There are $~\displaystyle \binom{n}{4}$ ways of selecting two elements from $\{~x_1,x_2,\cdots,x_n\}$ to form the two outlawed 2-cycles.
Then, there are $~3~$ distinct ways of pairing up these $~4~$ elements into two outlawed 2-cycles.
So,
$$T_2 = 3 \times \binom{n}{4} \times (n-4)!.$$
$\underline{\text{Computation of} ~T_r ~: 3 \leq r \leq c}$
First, you have to select the $~2r~$ elements, to be paired into the $~r~$ outlawed 2-cycles. This may be done in $~\displaystyle \binom{n}{2r}~$ ways.
Then, you have to form $~r~$ pairs, from these $~2r~$ elements.
This may be done in
$$~\binom{2r}{2} \times \binom{2r-2}{2} \times \cdots \times \binom{4}{2} \times \binom{2}{2} \times \frac{1}{r!}\\
= \frac{(2r)!}{2^r \times r!} ~~\text{ways}.$$
Note that the $~\dfrac{1}{r!}~$ over-counting adjustment factor represents that there are $~r!~$ ways of ordering each of the distinct groups of $~r~$ pairings.
Then, the $~(n-2r)~$ remaining elements are unrestricted in how they permute.
Therefore,
$$T_r = \binom{n}{2r} \times \frac{(2r)!}{2^r \times r!} \times (n-2r)!$$
$\underline{\text{Final Computation}}$
$$c = \left\lfloor \frac{n}{2}\right\rfloor.$$
$$T_0 = n!.$$
$$T_1 = \binom{n}{2} \times (n-2)!.$$
$$T_2 = 3 \times \binom{n}{4} \times (n-4)!.$$
For $~3 \leq r \leq c ~$ :
$$T_r = \binom{n}{2r} \times \frac{(2r)!}{2^r \times r!} \times (n-2r)!$$
The desired computation is
$$\sum_{r=0}^c (-1)^r T_r.$$