Note that all the logarithms here are of numbers between 0 and 1 (the output of sigmoid), so they are negative. Here is a graph of log(z) for 0 < z < 1:
Of course we know that log(1) = 0 because e^0 = 1.
So in the case of y = 1, what Prof Ng means by making log(\hat{y}) as large as possible is to make it as far to the right on that graph as possible, meaning a negative number that is as close to 0 as possible. Which will make the loss value -log(\hat{y}) as close to 0 from the positive side as possible.
Then for the y = 0 case, the loss is -log(1 - \hat{y}). So to make that as small as possible, you want \hat{y} to approach 0, which makes -log(1 - \hat{y}) approach 0.