A patent is way to encourage inventions, awarding the inventors the exclusive rights to their own inventions.
The public good is a priority. The idea is that the invention is beneficial to the public. If somebody creates a good invention but deny it from the public, this patent should not be in public interest anymore.