N 3d integer points in box with maximum average distance
Note that maximizing the average distance between every pair of points is the same as maximizing the total distance between every pair of points.

Let's look at an m x m square first. When N = 4, it is clear that the optimal solution is placing a point in each corner.

For N = 5, the next picture explores two alternatives of placing the 5th point when the other 4 are in the corners. It appears it is optimal to place the 5th point also in a corner. Note that in the right picture, which is already sub-optimal, the total solution does not improve when moving any of the other four points (which are in the corners).



This solution does not work for all N, but it generalizes to cubes when N is a multiple of 8. Then all points are in the eight corners in an optimal solution.