A title search is done to investigate past transfers of title and claims on a piece of property. If there is an issue, it usually shows up here. Title insurance is then issued for the rare chance it does not. You might think we live in a day where most if not all claims on land titles have been resolved, but unfortunately this is not the case. They are however few and far between.
So do not be worried, the chances of you purchasing a home and later claim getting a judgment to move you off of your property are almost unheard of. This is what title insurance is for. It protects you and the lender against these types of claims. If there ever was an issue, the insurance would kick in and pay for any damages. Almost all real estate transactions require a title search and title insurance (99.9% that have a mortgage).
Title search and insurance cost vary somewhat by state and county. A title search should be around $350-$750 and title insurance should between .05% to .07% of the purchase price or $500-$700 per $100,000