Of course it deals with polarity.
Generally speaking, all biatomic homonuclear molecules, such as N2, O2, F2, do NOT have any dipole moment: the distibution of the nuclear clouds is symmetrical. They are non-polar.
For what concerns heteronuclear molecules, it depends on their geometry. In order to provide a general scheme, remeber that what you call dipole moment, is the sum of all dipole moments in a molecule: they are vectors and their effect is a function of the geometry of the molecule, that you always have to work out from the formula.
To sum up, every time the sum of these vectors is not zero, because of geometry (free couples of electrons always play a key role in determining it), a molecule is polar. Otherwise it is non-polar.
In addiction, polarity of heteronuclear polyatomic molecules can be seen as a consequence of the presence of groups with different electronegativity.