Step 1: Rank by interaction with water:
Think about what each gas can do once it enters water.
$\text{HCl}$: it ionises fully and dissolves in huge amounts.
$\text{NH}_3$: it hydrogen bonds with water and forms $\text{NH}_4^+$, so it is also very soluble.
$\text{CO}_2$: a small part reacts to give $\text{H}_2\text{CO}_3$, which pulls more gas into solution.
$\text{N}_2$: nothing binds it to water. It is nonpolar and chemically inert at room temperature.
Step 2: Conclude:
With no reaction and no hydrogen bonding, nitrogen has the smallest solubility, roughly 0.02 mL per mL of water. The other three are all far higher.
Final Answer:
The least soluble gas is $\text{N}_2$, option (D).
\[ \boxed{\text{N}_2 \text{ (D)}} \]