N-queens problem objective function
The objective function you describe satisfies two properties:


It is maximized at a solution.
It is non-negative.


One can think of many other functions satisfying these two properties, for example $\binom{N}{2} - L + C$ for every $C \geq 0$. The exact choice is not so important – indeed, they chose $N^2/2$ whereas they could have chosen $\binom{N}{2} = N(N-1)/2$.