For example, the Wright brothers biggest contribution to aviation was suing everyone using wing warping (https://en.wikipedia.org/wiki/Wright_brothers_patent_war) which greatly advanced the adoption of the much more advanced ailerons.
Software patents have a similar effect, for example Cisco's patent on Virtual Router Redundancy Protocol led to the development of the more secure and more capable Common Address Redundancy Protocol (https://jacobfilipp.com/DrDobbs/articles/SA/v14/i05/a6.htm).
We tend to invest heavily in whatever we can get working first, but it's rarely close to an ideal way of doing something. By pushing every developer to find a newer, better way of doing something, patents prevent stagnation and lead to more advanced technologies.