A primary function of RNA is to provide a copy of DNA sequence, and to move out of nucleus (if a cell is a eukaryote). Once RNA is created, is serves a number of functions:
as mRNA, provides a template for protein synthesis by ribosome, with a sequence of amino acids corresponding to the sequence stored in DNA;
as rRNA, makes about half of the ribosome structure (the other half being proteins);
as tRNA, transports amino acids to a ribosome for inclusion in a polypeptide chain being synthesized;
some RNAs have enzymic activity (ribozymes), and act as enzymes; some small chunks of RNA have apparent regulatory function for various cell processes;
And and ur next question is because If DNA would directly have to translate into protein, there is a high risk of the loss of genetic material. Also DNA is very tightly packed, so unwinding it every now and then will not be energy efficient. Secondly, most of the regions of DNA do not code for a protein, so it is more logical to convert protein coding regions to mRNA. Thirdly, protein is translated on ribosomes (in cytoplasm) and so DNA has to migrate to cytoplasm to translate protein and the osmotic nature of cytoplasm may result in DNA damage. So the cellular machinery uses mRNA as an intermediate to produce protein.