Because they differ in the type and strength of intermolecular forces their molecules exhibit.
The state in which a compound can be found at room temperature and standard pressure depends on what type of intermolecular forces of attraction its molecules exhibit.
More precisely, it depends on the strength of these intermolecular forces. In your particular case, stronger intermolecular forces are associated with liquids and weaker intermolecular forces are associated with gases.
A more interesting comparison is between water,
It would be worth specifying that hydrogen fluoride boils at about
So let's asssume that you're working at a temperature of
All three molecules exhibit strong hydrogen bonding, a special type of dipole-dipole interactions that arise when hydrogen is directly bonded to one of the three most electronegative atoms - nitrogen, oxygen, and fluorine.
So why is ammonia a gas and room temperature, while water and hydrogen fluoride are liquids?
One reason for why that happens is because the difference in electronegativity between hydrogen and nitrogen is not as pronounced as the difference in electronegativity between hydrogen and oxygen or hydrogen and fluorine.
Another important reason is that these molecules have a different number of lone pairs present on the more electronegative atom.
In water's case, you have two partial positive hydrogen atoms and two lone pairs of electrons on the oxygen atom, which means that each water molecule can form hydrogen bonds with four other water molecules.
Hydrogen fluoride has three lone pairs of electrons, but only one hydrogen atom. This means that on average you will have insufficient partial positive hydrogen atoms to allow for the majority of hydrogen fluoride molecules to hydrogen bond at a particular moment.
Ammonia has three hydrogen atoms, but only one lone pair of electrons. This time, you will have insufficient lone pairs to allow for the majority of ammonia molecules to hydrogen bond at a particular moment.