Why did Portugal invade Macau?

It wasn't invaded. Macau was gifted to Portugal by the Chinese as a reward for clearing the Sea of China of all the Japanese pirates, which were plaguing that sea at the time.