Because if you didn't do that, you wouldn't have anywhere to return the list of free cells...
The first part of your code goes through and finds out how many cells are free:
int numberOfFreeCells = 0;
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++)
if (grid[i][j] == 0)
numberOfFreeCells++;
The second bit creates an array the right size to hold the free cell coordinates so you can return it:
int[][] freeCellList = new int[numberOfFreeCells][2];
The third chunk fills the array with the coordinates:
int count = 0;
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++)
if (grid[i][j] == 0) {
freeCellList[count][0] = i;
freeCellList[count++][1] = j;
}
And finally you return the array:
return freeCellList;