During DNA replication, RNA primase puts an RNA primer in the lagging strand. What is the function of this RNA primer? Why can't the enzymes put DNA fragments directly?
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.
In simple terms:
Function of the RNA primer: DNA polymerases need a double-stranded DNA region to which they can attach in order to begin copying the rest of the DNA strand. In order to provide this double-stranded attachment site, RNA primers are added by primase, an RNA polymerase which does not require such an attachment site itself.
When DNA replication starts, one primer is needed at the start of the leading strand. The lagging strand will need new primers regularly, and they mark the start of the stretches known as Okazaki fragments.
Why is RNA used instead of DNA?: Adding primers is an error-prone process, and DNA replication must copy the original strand with as high fidelity as possible. Using RNA for primers and then copying the original using DNA means that there is "memory" of which bits of the new strand were originally primers and hence more likely to contain errors (any RNA in the copy must have been primers). This allows removing them, in order to then replace them with proper high-fidelity DNA copies. When this happens, there is double-stranded DNA around the sites where primers were located, allowing DNA polymerases to attach there and fill in the gaps.
Aside from this, I would guess using RNA for priming may be more energy-efficient as RNA is more reactive than DNA.