Motivation for constructing $F$ s.t. $\ker(\text{curl}) \subset \text{Im}(\text{grad})$, $\ker(\text{div}) \subset \text{Im}(\text{curl})$ In 'from calculus to cohomology', we consider the space $V$ of smooth functions $U \to R^3$, with $U \subset R^3$ star-shaped (i.e. convex), and for cohomology reasons (showing $H^1(U)=H^2(U)=0$) we want to show that, viewing grad, curl and div as functions $C^{\infty}(U,\Bbb{R})\to C^{\infty}(U,\Bbb{R}^3)$,$C^{\infty}(U,\Bbb{R}^3)\to C^{\infty}(U,\Bbb{R}^3)$,$C^{\infty}(U,\Bbb{R}^3)\to C^{\infty}(U,\Bbb{R})$ respectively, we have ker$($curl$) \subset$ im$($grad$)$,  ker$($div$) \subset$ im$($curl$)$.
Question: The following constructions are made to show the above is true, and I would like to see the 'real' motivation behind these constructions. How does one think to make them? Are they just a special case of a larger object that the author was really thinking about when writing this?
Construction $1$ (in $\Bbb{R}^2$, but the construction is similar in $\Bbb{R}^3$): given $(f_1,f_2) \in$ker$($curl$)$, there exists an $F$ so that grad$(F)=(f_1,f_2)$,

Construction $2$: given $(f_1,f_2,f_3) \in$ker$($div$)$, there exists an $F$ so that curl$(F)=(f_1,f_2,f_3)$,

 A: It's illustrative to consider what happens on a domain with nontrivial cohomology, which in particular must be nonstarshaped.
onsider the domain
$$W := \mathbb{R}^3 - \{(0, 0, z) : z \in \mathbb{R}\},$$
that is, all of Euclidean $3$-space with the $z$-axis removed, and the
vector field
$${\bf X} := \frac{1}{x^2 + y^2}\langle -y, x\rangle$$
on $W$.
Computing directly gives that
$$\text{curl } {\bf X} = 0$$
but $\bf X$ is not the gradient of any function on $W$: Gradient vector fields are conservative, but computing gives that the integral of $\bf X$ along the oriented curve $\gamma: [0, 2 \pi]$ defined by
$$\gamma(t) := \langle \cos t, \sin t, 0 \rangle$$
is
$$\int_{\gamma} {\bf X} \cdot d{\bf s} = 2 \pi.$$
So, for the set $A$, $$\text{im } \text{curl} \not\subseteq \ker \text{grad},$$
and hence
$$H^1(A) = \frac{\ker \text{grad}}{\text{im } \text{curl}} \neq 0.$$
In fact, with a little more work we can show that any vector field in $\ker \text{curl}$ can be written as
$$a {\bf X} + \text{grad } f$$
for some constant $a \in \mathbb{R}$ and some function $f$, so
$$H^1(W) \cong \mathbb{R}.$$
This hints that the first cohomology group $H^1(S)$ of a space $S$ measures the presence of a certain type of hole in $S$.
Similarly, we can find a vector field on the set $B = \mathbb{R}^3 - \{(0, 0, 0)\}$ that is in $\ker \text{div}$ but not in $\text{im }\text{curl}$, and in facts that $H^2(B)$, and correspondingly $H^2(S)$ measures the presence of another type of hole in $S$.
So, conversely, if we show directly as in the given computation that $H^1(U) = 0$ and $H^2(U) = 0$ for some region $U$, then that region doesn't have the holes the cohomology groups detect.
This is, as you suspect, a special case of a much more general construction: There is a natural operator $d$ called the exterior derivative, which maps a $k$-form $\omega$ on $U$ to a $(k + 1)$-form we denote $d\omega$. Now, we say that a form $\omega$ is closed if $d\omega = 0$ and we say that it is exact if $\omega = d\alpha$ for some form $\alpha$. Computing directly gives that $d^2 = 0$, that is all closed forms are exact, so $\text{im } d \subseteq \ker d,$ and we define the \textit{$k$th (de Rham) cohomology group} to be $$H^k(U) := \frac{\ker d}{\text{im }d},$$ and each cohomology group (roughly speaking) detects a certain type of hole.
In the special case that we're working on a Riemannian $3$-manifold $(M, g)$ (an in particular, a subset $U \subseteq \mathbb{R}^3$ with the standard inner product), we can identify both $1$-forms on $U$ and $2$-forms on $U$ with vector fields on $U$ and $0$-forms and $3$-forms on $U$ with functions on $U$. Via these identifications, we can think of the exterior derivative $$d: \{\text{$0$-forms} \to \text{$1$-forms}\}$$ as a map $$\{\text{functions on $U$}\} \to \{\text{vector fields on $U$}\},$$
and we call this map the gradient. We can check that on subsets $U \subseteq \mathbb{R}^3$ this is given just by the usual formula. Similarly, the maps $$d: \{\text{$1$-forms} \to \text{$2$-forms}\}$$ and $$d: \{\text{$2$-forms} \to \text{$3$-forms}\}$$ can be regarded as maps we identify with $\text{curl}$ and $\text{div}$.
