They're short relative to other IP (like copyright), and short relative to inventions that have long R&D and cost recovery timelines. If $NEW_DRUG takes 5 years to develop, 5 years to trial, 5 years to market, and 5 years to profit...20 years isn't all that long.
If the invention takes 3 weeks and $0, yeah, 20 years is a long time.
…then the patent can be invalidated on the basis that it is obvious.
If the invention is commercially valuable, then invalidating it (or just pretending it doesn’t exist until you get sued, then invalidating it) can make more sense than licensing it.
A related issue is that there are many, many patents that most people (e.g., competitors) mostly ignore, because everyone, including the patent owner, knows that they would be invalidated if challenged.
If the invention takes 3 weeks and $0, yeah, 20 years is a long time.