What is a patent and How does it work?

What is a patent and How does it work?