(a) Role of the alkaline medium
Coupling is an electrophilic substitution in which the diazonium ion attacks the ring of the coupling partner (NCERT). The faster the ring gives up electrons, the faster the coupling.
In mildly alkaline solution phenol is converted to the phenoxide ion. The negatively charged oxygen donates its lone pair into the ring much more strongly than a neutral –OH group, putting a large negative charge on the ortho and para carbons:

The diazonium ion attacks the para carbon, which is electron-rich and not crowded:
C6H5N2+Cl−+C6H5OH+NaOH→p-HOC6H4N=NC6H5+NaCl+H2O

In an acidic medium phenol stays as neutral C6H5OH, whose ring is far less activated, so coupling becomes very slow.
(b) No coupling with benzene or nitrobenzene
The positive charge of the benzenediazonium ion is spread into its own ring by resonance, so the terminal nitrogen is only weakly electrophilic. It can attack only rings that are strongly activated by powerful electron donors such as –O−, –OH or –NH2. Benzene has no such donor, and nitrobenzene's ring is deactivated by –NO2, so neither reacts. The benzenediazonium ion is a weak electrophile.