The primary function of a bad bank is to clean up the balance sheets of commercial banks by purchasing their NPAs, allowing the commercial banks to focus on normal banking activities like lending.