A patent search checks whether an invention is genuinely new by looking for existing patents and published applications covering the same ground. It is the step that decides whether filing is worth the cost, and it is far cheaper than finding out during examination.
Because keywords alone miss things. Patent drafting favours broad, unusual language, and an invention described as a "fastening assembly" will not surface in a search for "clip".
Classification codes group patents by what they do rather than what they are called, which is why professional searchers lead with them.
Whether you are free to sell. A search for novelty asks whether your invention can be patented. Freedom to operate asks whether making it would infringe someone else's patent, and it is a separate exercise.
An expired patent also still counts as prior art. It can block your application even though nobody can enforce it any more.