5. Given the ellipse $\frac{x^{2}}{16}+\frac{y^{2}}{4}=1$ with its left and right foci being $F_{1}$ and $F_{2}$, respectively, point $P$ lies on the line
$$
l: x-\sqrt{3} y+8+2 \sqrt{3}=0
$$

When $\angle F_{1} P F_{2}$ takes its maximum value, $\frac{\left|P F_{1}\right|}{\left|P F_{2}\right|}=$ $\qquad$
5. $\sqrt{3}-1$.

Notice, to make $\angle F_{1} P F_{2}$ maximum, the circle passing through points $F_{1}$, $F_{2}$, and $P$ must be tangent to line $l$ at point $P$. Line $l$ intersects the $x$-axis at point $A(-8-2 \sqrt{3}, 0)$.
Thus, $\angle A P F_{1}=\angle A F_{2} P$
$\Rightarrow \triangle A P F_{1} \backsim \triangle A F_{2} P$
$\Rightarrow \frac{\left|P F_{1}\right|}{\left|P F_{2}\right|}=\frac{|A P|}{\left|A F_{2}\right|}$.
By the power of a point theorem,
$|A P|^{2}=\left|A F_{1}\right|\left|A F_{2}\right|$.
Notice, $F_{1}(-2 \sqrt{3}, 0), F_{2}(2 \sqrt{3}, 0)$,
$A(-8-2 \sqrt{3}, 0)$.
Then $\left|A F_{1}\right|=8,\left|A F_{2}\right|=8+4 \sqrt{3}$.
Thus, $\frac{\left|P F_{1}\right|}{\left|P F_{2}\right|}=\sqrt{\frac{\left|A F_{1}\right|}{\left|A F_{2}\right|}}=\sqrt{\frac{8}{8+4 \sqrt{3}}}$
$=\sqrt{4-2 \sqrt{3}}=\sqrt{3}-1$.