The primary purpose of a parapet wall is to provide a safety barrier on rooftops and terraces, preventing falls and enhancing building safety.