It's written explicitly in the U.S. Constitution:
To promote the Progress of Science and useful Arts,
by securing for limited Times to Authors and Inventors the exclusive Right
to their respective Writings and Discoveries.