It cost time and money.
If your invention already exists somewhere, why not let the patent court discover it and reject your application?
At the point of applying it would a patent examiner or searcher employed by the patent office not a court. If it ever gets to court the court does no searching but the other party certainly does.
I recommend searches for several reasons. (1) Paying a professional to draft and file an application could be between $6k and $20k. A professional searcher will cost between $200 and $1,000. So if you decide not to draw up an application you have saved money. (2) It could take a year or more before you get the result of the examiners search. (3) As someone drafting an application I want to know the standard terms used in patents in the field. (4) Of #1 importance - there may be several interesting aspects of your invention and if the one you are hanging your hat on is not new, maybe another aspect is new and the application should focus there. Or maybe it will take careful claim drafting to make a novel claim.
I know one person who says when you search and find it has already been done “then the real inventing starts”. It may be that the concept is too expensive or difficult to use. Now you have a new starting point to invent something even better.
I think the rational for doing a prior art search is that it is expensive to hire a lawyer to draft and file patent applications so if there is some killer prior art you are better of knowing about it. Additionally if there is some close prior art, you may be better off acknowledging it and pointing out in the application why your invention is patentable despite it.
On the other hand, I've actually had patent lawyers ask me not to do prior art searches under the theory that you have to disclose prior art you are aware of and the examiner might not find everything relevant. However I suspect this is a minority view.