Derivation of tensor (with einstein summation) Let $f$ be a scalar defined by:
$$f = a_{iik}a_{kjj} (1 \leq i, j, k \leq 3)$$
in which $a$ is a third-rank tensor $a_{ijk} = a_{jik}$ and the summation convention for repeated indices is employed.
Now, we define $g = \frac{\partial f}{\partial a}$. Someone please explain to me why do we get:
$$g_{pqr} = \frac{1}{2}(a_{iip} \delta_{qr} + 2a_{rii} \delta_{qp} + a_{iiq} \delta_{pr})$$
where $\delta$ is the Kronecker delta.

As Peter Michor pointed out your formula is not correct without further symmetries. In the case of a general tensor one can use the product rule to find the derivative of $f$ (assuming euclidean tensors):
\begin{equation}
\frac{\partial f}{\partial a_{pqr}} = \frac{\partial a_{iik}}{\partial a_{pqr}} a_{kjj} + a_{iik}\frac{\partial a_{kjj}}{\partial a_{pqr}}
\end{equation}
where for a general tensor it holds that $\frac{\partial a_{lmn}}{\partial a_{pqr}} = \delta_{lp}\delta_{mq}\delta_{nr} $. All that is left to do are the contractions and relabeling of indices to find 
$$
\frac{\partial f}{\partial a_{pqr}} = \delta_{pq}a_{rii} + a_{iip}\delta_{qr}
$$
It seems that your tensor $a$ must be symmetric under exchange of its first two indices: $a_{ijk} = a_{jik}$, because under these conditions you will get for the derivative:
$$
\frac{\partial a_{ijk}}{\partial a_{pqr}} = S_{ij,pq} \delta_{kr}
$$
where $S$ is the symmetrizer tensor: $S_{ij,pq} = \frac{1}{2}(\delta_{ip} \delta_{jq} + \delta_{iq} \delta_{jp})$ and substitution in the product rule gives the result you quoted above:
$$
\frac{\partial f}{\partial a_{pqr}} = \frac{1}{2} (2 \delta_{pq} a_{rii} + \delta_{rq}a_{iip} + \delta_{rp}a_{iiq})
$$
