A patent is a legally protected property interest. It is essentially an agreement between an inventor of a useful invention and the government. In exchange for full disclosure of the invention, the government grants the inventor the right to exclude others from making, using, selling, offering to sell and importing the patented invention -- but only if certain "patentability" requirements are met. Specifically, the invention not only has to be useful, but it must also be new and non-obvious over the state of the art.
Patents exist are "legal monopolies" which provide an incentive for inventors to disclose their inventions to the public. Without patents, inventors might be unwilling to invest time and resources in developing their inventions, or even if they do develop their inventions, they might otherwise have no incentive to make the inventions public.