What is the function of the RNA primer in DNA replication?
DNA polymerases need a primer oligonucleotide (RNA or DNA) - their substrates are an existing 3'-OH group and a dNTP. The primase however is a typical RNA polymerase, capable of initiating polynucleotide synthesis de novo by positioning a complementary ribonucleoside 5'-triphosphate opposite its complementary DNA base. The primase makes an RNA primer that the DNA polymerase can then use for chain extension. The RNA primer is ultimately degraded and replaced by a DNA polymerase.

The rationale for this difference is that DNA polymerases have an active site that is geared towards proofreading and that primerless initiation would be an error-prone process. By having the primers 'tagged' by virtue of them being RNA, it is possible for the replication machinery to use them but then replace them with a high fidelity DNA copy of the template strand.

Edit in response to OP comment:
Synthesis of the leading strand consists of extending an existing DNA. However the leading strand is also originally initiated, at the ori element, with an RNA primer. Once that first initiation event has taken place the synthesis of the leading strand is simply a process of extending that original primer.

Some viruses employ ingenious variations on this theme such as using tRNA primers , or proteins - see Wikipedia.