The equation for this matrix comes from transformation rule:
$$
\begin{pmatrix}x_1\\y_1\\z_1\\1\end{pmatrix} =
\begin{pmatrix}R_{11}&R_{12}&R_{13}&t_1\\
R_{21}&R_{22}&R_{23}&t_2\\
R_{31}&R_{32}&R_{33}&t_3\\
0&0&0&1\end{pmatrix}
\begin{pmatrix}x\\y\\z\\1\end{pmatrix} $$
$$
x_1=R_{11}x+R_{12}y+R_{13}z+t_1,\\
y_1=R_{21}x+R_{22}y+R_{23}z+t_2,\\
z_1=R_{31}x+R_{32}y+R_{33}z+t_3,
$$
Transformation matrix is usually presented as follows:
$$
A_1 = \begin{pmatrix}R_{11}&R_{12}&R_{13}&t_1\\
R_{21}&R_{22}&R_{23}&t_2\\
R_{31}&R_{32}&R_{33}&t_3\\
0&0&0&1\end{pmatrix} = \begin{pmatrix}
\mathbf R&\mathbf t \\
\mathbf 0& 1
\end{pmatrix},
$$
where $\mathbf R$ is $3\times3$ ($n\times n$ in general) rotation matrix and $\mathbf t$ is a $3\times1$ translation vector.
If we expand the transformation rule
$$
\begin{pmatrix}\mathbf r_1\\1\end{pmatrix} =
\begin{pmatrix}x_1\\y_1\\z_1\\1\end{pmatrix} =
\begin{pmatrix}R_{11}&R_{12}&R_{13}&t_1\\
R_{21}&R_{22}&R_{23}&t_2\\
R_{31}&R_{32}&R_{33}&t_3\\
0&0&0&1\end{pmatrix}
\begin{pmatrix}x\\y\\z\\1\end{pmatrix} =
\begin{pmatrix}
\mathbf R&\mathbf t \\
\mathbf 0& 1
\end{pmatrix}\begin{pmatrix}\mathbf r\\1\end{pmatrix}
$$
we get an alternative way to present an affine transformation is like:
$$
\mathbf r_1=\mathbf R\mathbf r + \mathbf t
$$
So now we need to first deal with rotation (we forget about translation as if $\mathbf t=0$ or coordinate origins coincide). We see that if we take the vector $\mathbf i=(1,0,0)^\intercal$, then rotated vector $\mathbf i_1=\mathbf R\mathbf r=(R_{11}, R_{21}, R_{31})^\intercal$. From the picture we know, that $\mathbf i_1$ is looking down, so $\mathbf i_1=(0,0,-1)^\intercal$ and that help us to find the first column in matrix $\mathbf R$. We repeat the procedure for vectors $\mathbf j$ and $\mathbf k$ and find the row of matrix $\mathbf R$.
To find a translation vector is even simpler. The vector $\mathbf r=\mathbf 0$ will go to $\mathbf r_1=\mathbf t$, so $\mathbf t$ is just the position of new origin in old coordinate system. From the picture we see that $\mathbf t=(1,2,2)^\intercal$.
By arranging everything to the transformation matrix, we get the answer.