A major source of this problem IMO is the granting of bullshit patents in the first place - patents that should never have been granted because they’re obvious and/or there was prior art. Patent clerks aren’t actually subject matter experts in the field, and there’s little incentive for them to deny bullshit patents. They maybe deny them once or twice, but dedicated companies just keep applying and eventually get them granted, because the applicant has a major incentive to get the bullshit patent, and the patent office has only minor incentives to deny bullshit patents. I think these incentives need to be changed - for example, if company A sues company B over patent C, company B spends $10 million on their defence, and wins with the patent being deemed invalid, I think company B should get MAJOR financial rewards from BOTH company A and the patent office, on the order of 10x+ what they spent on their defence. If granting a bullshit patent was a $100 mil mistake, patent offices would be WAY more careful with the patents they grant, and applying for patents would be WAY more expensive, and those are both good things!
The right incentives could keep the good parts of the patent system while eliminating the (currently pretty massive, out of control) downsides. Patents are currently a mediocre idea implemented incredibly poorly.