Why do we say that the first person to think of an invention gets it all to his/herself? It’s a free country, ain’t it? As others have said, it’s a societal bargain. We give people a monopoly for a limited period to encourage R&D. In olden days, it was done by monarchs.
BTW, patent and copyright are different in a fundamental way. Copyright covers only the particular expression (book, song, etc.). Subject to fair use and a few other exceptions, no one else can copy, sell or perform the work without the author’s consent. Ideas, however, can’t be copyrighted. You can’t copyright The Best Friggin’ Burger In The World. Only the particular words used in your recipe are protected. Someone else can write a similar recipe that produces the exact same burger without violating your copyright. Patent, by contrast, protects the burger. No one else can make that burger for the duration of the patent. How different someone else’s burger has to be without infringing your patent is one of those things people fight over all the time.
Note: TBFBITW would not be patentable - it’s not original enough - but you get the idea.