5. A point $P$ in space is at distances of $2$ and $3$ from the vertices $A$ and $B$ of a regular tetrahedron $ABCD$. When the edge length of the tetrahedron changes, the maximum distance from point $P$ to the line $CD$ is . $\qquad$
5. $\frac{5 \sqrt{3}}{2}$.

When the tetrahedron is determined, the trajectory of point $P$ is also determined, and the plane of the trajectory is perpendicular to $AB$. Take the midpoint $E$ of $CD$. Only when point $P$ is located in the plane $ABE$ and on the opposite side of $E$ with respect to $AB$, can the distance from $P$ to $CD$ reach its maximum value.

Thus, the problem is transformed into: "In the same plane, given that the distances from point $P$ to the vertices $A$ and $B$ of $\triangle ABE$ are $2$ and $3$ respectively, and $AE = BE = \frac{\sqrt{3}}{2} AB$. When the side lengths of $\triangle ABE$ change, find the maximum distance from point $P$ to point $E$."
As shown in Figure 2, construct $\angle P^{\prime}AE = \angle PAB$, such that
$$
\begin{aligned}
& P^{\prime}A = \frac{\sqrt{3}}{2} AP. \\
\text{By } & \frac{P^{\prime}A}{PA} = \frac{AE}{AB} = \frac{\sqrt{3}}{2}, \angle PAB = \angle P^{\prime}AE \\
\Rightarrow & \triangle APB \sim \triangle AP^{\prime}E \\
\Rightarrow & P^{\prime}E = \frac{\sqrt{3}}{2} PB = \frac{3\sqrt{3}}{2}. \\
\text{Also, } & \frac{AP}{AB} = \frac{AP^{\prime}}{AE}, \angle PAP^{\prime} = \angle BAE \\
\Rightarrow & \triangle APP^{\prime} \sim \triangle ABE \\
\Rightarrow & PP^{\prime} = \frac{\sqrt{3}}{2} PA = \sqrt{3}.
\end{aligned}
$$

Therefore, $PE \leqslant PP^{\prime} + P^{\prime}E = \frac{5\sqrt{3}}{2}$.