The main purpose of foreclosure is to recover the amount the lender gave to the borrower to purchase the property. The process helps the lender take ownership of the property and sell it to recover the amount. The foreclosure process varies from state to state, and most lenders try to work with the borrowers to avoid foreclosure.