there can be a very good case made for putting private innovation into the public realm after a period of legal protections, (typically 20 years for most places)
but anything that is public by it's very nature should never be subject to patents
Even for those 20 years it can be incredibly suffocating in fast moving industries like IT. Just look at e.g. the way video codecs got mutilated by patents.
patents where invented to protect trade secrets with the result of making them public being an unavoidable consequence. I didn't mean to make it sound like I agree with intellectual property of any kind just to say there are good reasons and good outcomes.
The internet doesn't tend to be the place to discuss nuance however.
I think the 20 years are just a bad "one size fits all" value, maybe lawmakers could be convinced to tie it to something like the typical product support lifecycle in the relevant industry. That would give companies that do want long patent protections an incentive to support their products for a longer time, benefiting the end user either way.