Step 1: Why aniline is hard to nitrate directly.
The \(-NH_2\) group is a very strong activating, electron-releasing group. It makes the benzene ring so reactive that nitration is hard to control and would give a mixture with a lot of unwanted product.
Step 2: The oxidation problem.
Nitration uses strong nitric acid, which is also a strong oxidising agent. Since aniline is easily oxidised, direct nitration can destroy part of it by oxidation, lowering the yield.
Step 3: Protect the amino group.
To solve both problems, aniline is first acetylated by treating it with acetic anhydride. This changes \(-NH_2\) into \(-NHCOCH_3\) (acetanilide).
Step 4: Effect of acetylation.
The acetamido group \((-NHCOCH_3)\) is much less strongly activating than \(-NH_2\), because the nitrogen lone pair is partly tied up with the carbonyl. So the ring is calmed down and is no longer easily oxidised, allowing controlled nitration mainly at the para position.
Step 5: Remove the protection.
After nitration, the acetyl group is removed by hydrolysis to get back the free \(-NH_2\) group, giving p-nitroaniline cleanly.
Answer: The \(-NH_2\) group is acetylated first because it converts the strongly activating, easily oxidised \(-NH_2\) into the milder \(-NHCOCH_3\) group. This controls the high reactivity, prevents oxidation by nitric acid, and allows clean nitration; the amino group is restored afterwards by hydrolysis.