What is the need for prediction filter in PCM and DPCM?
The DPCM works by the difference between actual samples and predicted samples. 
  
  If we already have the actual samples, we can quantize it and encode it later. 
  
  
  But why we use prediction filter? 
  


the idea is to transmit the D (or $e[n]$) and let the receiver add that to the previous PCM sample it has (or can predict from the previous PCM samples using the same predictor).  and the reason was that, if the prediction was good, then $e[n]$ would be small and a smaller word width was needed. 


  
  And by the definition "predicts the present samples with previous samples" how does the filter do that? 
  


the idea is that a good prediction of $x[n]$ is a linear combination of $x[n-1]$, $x[n-2]$, $x[n-3]$, $x[n-4]$... $x[n-N]$.  so some guys in the sixties just suggested that the prediction is:

$$ \hat{x}[n] \triangleq a_1\, x[n-1] \ + \ a_2\, x[n-2] \ + \ a_3\, x[n-3] \ + ... + \ a_N\, x[n-N]   $$

the prediction error is

$$ e[n] \triangleq \hat{x}[n] - x[n] $$

and this $e[n]$ is what is transmitted and the next PCM sample can be constructed from the previous PCM samples and the error as

$$ \begin{align}
 x[n] &amp;= \hat{x}[n] \ - \ e[n] \\ 
      &amp;=  a_1\, x[n-1] \ + \ a_2\, x[n-2] \ + \ a_3\, x[n-3] \ + ... + \ a_N\, x[n-N] \ - \ e[n] 
\end{align} $$

you can see that the prediction is a linear FIR filter and that the reconstruction has feedback and is a linear IIR filter (that happens to have all of the zeros at the origin, sometimes called an "all-pole filter" which is slightly imprecise).

then the idea is to, with knowledge of the statistical spectral characteristics of $x[n]$, namely its autocorrelation, find the values of $a_1$, $a_2$, $a_3$, ... such that the prediction is the best, that is such that $|e[n]|^2$ is minimized in a statistical manner.  this is what linear predictive coding (LPC) is at the most fundamental.  smaller $e[n]$ means that the word width needed for that signal is smaller and that the number of bits you need to send $e[n]$ over a transmission channel is less.  and, it means you can add Shannon and Huffman to the mix and send even fewer bits over the channel.  that is one way to do lossless coding.