Gravity exerts a force on each mass, and when the forces balances, we know the unknown mass is equal to that of the standard.