Given two categories $\mathsf{C},\mathsf{D}$ with $\mathsf C$ small, their functor category, denoted either $\text{Fun}(\mathsf{C},\mathsf{D})$ or $\mathsf{D}^{\mathsf C}$, is defined as a category whose objects are functors $F:\mathsf C\to\mathsf D$ and whose morphisms are natural transformations between functors $\alpha:F\implies G$. Composition between morphisms in the functor category is defined via componentwise composition of natural transformations in $\mathsf{D}$, as shown in the following diagram:
Here are some examples and fun facts about functor categories:
$\text{Fun}(\mathbb 1,\mathsf C)\cong\mathsf C$ and $\text{Fun}(\mathsf C,\mathbb 1)\cong\mathbb 1$.
If $\mathsf{X}$ is a small discrete category, then $\text{Fun}(\mathsf X,\mathsf C)$ is isomorphic to a category whose objects consist of all functions from $\text{ob}(\mathsf X)$ to $\text{ob}(\mathsf C)$.
Taking the functor category commutes with taking the opposite category . That is, $\text{Fun}(\mathsf{C}^\text{op},\mathsf{D}^\text{op})=\text{Fun}(\mathsf C,\mathsf D)^\text{op}$, as can be seen by reversing arrows in the above diagram.
The functor category $\text{Fun}(\mathbb 2,\mathsf C)$ can be thought of as a category whose objects are the morphisms of $\mathsf C$ and whose morphisms are the commutative squares connecting pairs of morphisms of $\mathsf C$.
If $\mathsf{FinSet}$ is the category of finite sets, then $\text{Fun}(\mathsf{B}G,\mathsf{FinSet})$ is the category of all permutation representations of $G$, where $G$ is a finite group. Similarly, $\text{Fun}(\mathsf{B}G,\mathsf{Vect}_\mathbb k)$ is the category of all representations of $G$ as a group of matrices over $\mathbb k$.
$\text{Fun}(\mathsf C, \mathsf B\mathbb N)$ is the category of discrete dynamical systems, whose objects are sets $X$ each equipped with a function $f:X\to X$ and whose morphisms are functions which preserve the distinguished function. (Note: $\mathsf B\mathbb N$ here denotes the monoid $\mathbb N$ regarded as an abstract category with one object.)
Proposition 1. If $\mathsf{C,D}$ are categories where $\mathsf{C}$ is small and $\mathsf{D}$ has pullbacks , then $\mathsf{D}^\mathsf C$ has pullbacks.
Proof. Suppose $\mathsf C$ is small and $\mathsf D$ has pullbacks. We shall show that if $F\overset{\alpha}\Rightarrow H\overset{\beta}\Leftarrow G$ are two natural transformations between functors $F,G,H:\mathsf C\to\mathsf D$, i.e. morphisms in the category $\mathsf{D}^\mathsf C$, then the following square is a pullback in $\mathsf{D}^\mathsf C$ for some functor $\Phi:\mathsf C\to\mathsf D$ and some natural transformations $\gamma,\delta$:
Let us now define $\Phi,\gamma$ and $\delta$. We shall define the components $\gamma_x$ and $\delta_x$ and the action of $\Phi$ on objects by defining $\gamma_x,\delta_x,\Phi x$ as the unique morphisms/objects (up to isomorphism) that make the following a pullback square (since $\mathsf D$ has pullbacks):
It remains to define how $\Phi$ acts on morphisms. If $f:x\to y$ is a morphism in $\mathsf C$, then we know that there exists a unique arrow (dashed) making the following diagram commute, by the fact that the outer quadrilateral commutes and that the inner square is a pullback:
where the fact that $\beta_y\circ Gf\circ \delta_x = \alpha_y\circ Ff\circ \gamma_x$ can be deduced by examining the following cube:
where the orange-outlined squares commute by naturality of $\alpha$ and $\beta$, and the blue corners denote pullback squares. Therefore, we may define $\Phi f$ unambiguously as the unique morphism $\Phi x\to\Phi y$ to take the place of the green dashed arrow that would make the former diagram commute, since the lower square is a pullback square by the definition of $\Phi x,\gamma_x,\delta_x$.
We have now completely define $\Phi,\gamma$ and $\delta$, but we have not yet shown functoriality of $\Phi$, nor have we shown naturality of $\gamma$ and $\delta$. Functoriality of $\Phi$ follows from an examination of the following diagram, where $f:x\to y$ and $g:y\to z$ are morphisms in $\mathsf C$:
By the pullback property, there exists a unique morphism $\Phi x\to \Phi z$ making the diagram commute, and since $\Phi(gf)$ and $(\Phi g)(\Phi f)$ both make it commute, we have that $\Phi(gf)=(\Phi g)(\Phi f)$, proving functoriality.
As for naturality, recall that we defined $\Phi$ such that $\gamma_y (\Phi f)=(Ff)\gamma_x$ and $\delta_y (\Phi f)=(Gf)\delta_x$ whenever $f:x\to y$ - see the previous commutative diagram in which $\Phi f$ was defined as the unique morphism capable of replacing a green dashed arrow to make the diagram commute. These equalities, however, are simply the naturality conditions for $\gamma$ and $\delta$.
Now, because $\Phi$ is a pullback of $\beta$ along $\alpha$ componentwise, it follows that it must be a pullback of $\beta$ along $\alpha$ in $\mathsf D^\mathsf C$. For if $\Psi$ were another functor with natural transformations $\gamma',\delta'$ forming a commutative square with $\alpha,\beta$, we could (uniquely) assemble a natural transformation $\phi:\Psi\Rightarrow\Psi$ making $\gamma'=\gamma\phi$ and $\delta'=\delta\phi$ by considering the componentwise pullback squares. (Naturality of $\phi$ could then be proven by considering $(\Phi f)\phi_x$ and $\phi_y (\Psi f)$ as morphisms $\Psi x\to \Phi y$ making another pullback diagram commute, so that uniqueness of such a morphism implies their equality $(\Phi f)\phi_x = \phi_y (\Psi f)$.) Hence, we have that $\Phi$ is a pullback in the functor category $\mathsf D^\mathsf C$ as claimed. $\blacksquare$