Inclusion
Provide written informed consent =\< 28 days prior to randomization
Willing to return to enrolling institution for follow-up (during the Active Monitoring Phase of the study)
NOTE: During the Active Monitoring Phase of a study (i.e., active treatment and clinical follow-up), participants must be willing to return to the consenting institution for follow-up
Age \>= 18 years
Hepatocellular carcinoma (HCC) confirmed by histological/cytological diagnosis or clinically per the American Association for the Study of Liver Diseases (AASLD) or WASL 2018 criteria
Locally advanced, metastatic and/or unresectable disease that is not amendable to curative treatment
Previously progressed on atezolizumab in combination with bevacizumab as first line systemic therapy for advanced disease
NOTE: 2nd line patients only
Eastern Cooperative Oncology Group (ECOG) Performance Status 0 or 1
Child Pugh class A
Documented virology status of hepatitis, as confirmed by screening hepatitis B virus (HBV) and hepatitis C virus (HCV) serology tests.
For subjects with active HBV, HBV deoxyribonucleic acid (DNA) \< 500 IU/mL obtained ≤ =\< 28 days prior to randomization, and anti-HBV treatment (per local standard of care; e.g., entecavir) for a minimum of 14 days prior to randomization and willingness to continue treatment for the length of the study
At least one measurable untreated malignant lesion per RECIST v1.1. Subjects who previously received local therapy (e.g., ablation, percutaneous ethanol injection, trans-arterial embolization/chemo-embolization) are eligible provided the target lesion(s) have not been previously treated with local therapy or the target lesion(s) within the field of local therapy have subsequently progressed in accordance with RECIST v1.1
Consent to using archival tumor tissues, if available
NOTE: Non-availability of tumor tissue does not exclude the subject.
Willingness to provide mandatory blood specimens for correlative research
Willingness to provide mandatory tissue specimens for correlative research for the first 10 patients per arm (Mayo Clinic Rochester and Mayo Clinic Arizona ONLY)
Absolute neutrophil count (ANC) \>= 1.5 x 10\^9/L (1500/uL) without granulocyte colony-stimulating factor support (obtained =\< 28 days prior to randomization)
Lymphocyte count \>= 0.5 x 10\^9/L (500/uL) (obtained =\< 28 days prior to randomization)
Platelet count \>= 75 x 10\^9/L (75,000/uL) (obtained =\< 28 days prior to randomization)
Hemoglobin \>= 90 g/L (9 g/dL) (obtained =\< 28 days prior to randomization)
Subjects may be transfused to meet this criterion
Aspartate aminotransferase (AST), alanine aminotransferase (ALT), and alkaline phosphatase (ALP) =\< 5 x upper limit of normal (ULN) (obtained =\< 28 days prior to randomization)
Total bilirubin =\< 3 x ULN (obtained =\< 28 days prior to randomization)
Serum albumin \>= 30 g/L (3.0 g/dL) (obtained =\< 28 days prior to randomization)
For subjects not receiving therapeutic anticoagulation: international normalized ratio (INR) or partial thromboplastin time (aPTT) =\< 1.5 × ULN (obtained =\< 28 days prior to randomization)
Serum creatinine =\< 2 x ULN or creatinine clearance \>= 30 mL/min (calculated using the Cockcroft-Gault formula) (obtained =\< 28 days prior to randomization)
Negative pregnancy test done =\< 14 days prior to randomization, for women of childbearing potential only
NOTE: If the urine test is positive or cannot be confirmed as negative, a serum pregnancy test will be required
Resolution of any acute, clinically significant treatment-related toxicity from prior therapy to grade =\< 1 prior to randomization, with the exception of alopecia and peripheral sensory neuropathy.
Subjects of childbearing potential agree to use two forms of medically approved contraception while taking the study drug and for at least 5 months after the last dose of atezolizumab or multi-kinase inhibitor. Subjects with partners of childbearing potential agree to use condoms, even after vasectomy, to avoid potential drug exposure to partner during study drug and for 5 months following the last dose of study drug
Ability to take oral medications
Exclusion
Known diagnosis of fibrolamellar carcinoma, sarcomatoid carcinoma or mixed hepatocellular cholangiocarcinoma
Prior multi-kinase inhibitor treatment for advanced disease (e.g., cabozantinib, lenvatinib, sorafenib, regorafenib)
NOTE: Use of multi-kinase inhibitor(s) for adjuvant or as part of loco-regional therapies is allowed as long as the therapy was completed \>= 6 months prior to randomization
Any of the following prior therapies:
Major surgery =\< 4 weeks prior to randomization; Minor surgery =\< 7 days prior to randomization (e.g., simple excision, tooth extraction, insertion of central lines/Mediport). Subjects with clinically relevant complications from prior surgery are not eligible
Any anti-cancer agent =\< 2 weeks prior to randomization
Radiation therapy =\< 4 weeks (1 week for palliative radiation for bone metastases and/or for pain control) or radionuclide treatment (e.g., I-131 or Y-90) =\< 6 weeks prior to randomization
Treatment with investigational therapy =\< 28 days prior to randomization
Known brain or leptomeningeal metastasis
Known co-infection of HBV and HCV. Subjects with a history of HCV infection but who are negative for HCV ribonucleic acid (RNA) by polymerase chain reaction (PCR) will be considered non-infected with HCV
Active or history of autoimmune disease or immune deficiency, including, but not limited to, myasthenia gravis, myositis, autoimmune hepatitis, systemic lupus erythematosus, rheumatoid arthritis, inflammatory bowel disease, antiphospholipid antibody syndrome, Wegener granulomatosis, Sjogren syndrome, Guillain-Barre syndrome, or multiple sclerosis with the following exceptions:
Subjects with a history of autoimmune-related hypothyroidism who are on thyroid-replacement hormone are eligible for the study
Subjects with controlled Type 1 diabetes mellitus who are on an insulin regimen are eligible for the study
Subjects with eczema, psoriasis, lichen simplex chronicus, or vitiligo with dermatologic manifestations only (e.g., subjects with psoriatic arthritis are excluded) are eligible for the study provided all of the following conditions are met:
Rash must cover \< 10% of body surface area
Disease is well controlled at baseline and requires only low-potency topical corticosteroids
No occurrence of acute exacerbations of the underlying condition requiring psoralen plus ultraviolet A radiation, methotrexate, retinoids, biologic agents, oral calcineurin inhibitors, or high-potency or oral corticosteroids within the previous 12 months
History of idiopathic pulmonary fibrosis, organizing pneumonia (e.g., bronchiolitis obliterans), drug-induced pneumonitis, or idiopathic pneumonitis, or evidence of active pneumonitis on screening chest computed tomography (CT) scan
NOTE: History of radiation pneumonitis in the radiation field (fibrosis) is permitted
Any other disease, metabolic dysfunction, physical examination finding, or clinical laboratory finding that contraindicates the use of an investigational drug, may affect the interpretation of the results, or may render the subject at high risk from treatment complication
Treatment with a live, attenuated vaccine =\< 4 weeks prior to randomization, or anticipation of need for such a vaccine during atezolizumab treatment or =\< 5 months after the last dose of atezolizumab
History of severe allergic anaphylactic reactions to chimeric or humanized antibodies or fusion proteins
Known hypersensitivity to Chinese hamster ovary cell products or to any component of the atezolizumab formulation
Subjects with untreated or incompletely treated esophageal/gastric varices with bleeding or high risk for bleeding. Subjects treated with adequate endoscopic therapy (according to local institutional standards) without any episodes of recurrent gastrointestinal bleeding requiring transfusion or hospitalization for \> 28 days prior to randomization are eligible
Treatment with systemic immunostimulatory agents (including, but not limited to, interferon and interleukin 2 \[IL-2\]) =\< 4 weeks or 5 drug elimination half-lives (whichever is longer) prior to randomization
Prior treatment with CD137 agonists or immune checkpoint blockade therapies, including anti-CTLA-4, anti-PD-1, and anti-PD-L1 therapeutic antibodies
Note: Prior treatment with atezolizumab is permitted
Treatment with systemic immunosuppressive medication (including, but not limited to, corticosteroids, cyclophosphamide, azathioprine, methotrexate, thalidomide, and anti-TNF alpha agents) =\< 2 weeks prior to randomization, or anticipation of need for systemic immunosuppressive medication during study treatment, with the following exceptions:
Subjects who received acute, low-dose systemic immunosuppressant medication or a one-time pulse dose of systemic immunosuppressant medication (e.g., 48 hours of corticosteroids for a contrast allergy) are eligible for the study
Subjects who received mineralocorticoids (e.g., fludrocortisone), corticosteroids for chronic obstructive pulmonary disease (COPD) or asthma, or low-dose corticosteroids for orthostatic hypotension or adrenal insufficiency are eligible
For subjects who are to receive cabozantinib: Treatment with strong inducers and/or strong inhibitors of CYP3A4 =\< 14 days prior to randomization, including rifampin (and its analogues) or St. John's wort. See https://www.fda.gov/drugs/drug-interactions-labeling/drug-development-and-drug-interactions-table-substrates-inhibitors-and-inducers for lists of known strong inhibitors and strong inducers of CYP3A4
Active tuberculosis
Other uncontrolled, significant intercurrent or recent illness including, but not limited to, the following conditions:
Cardiovascular disorders including:
Symptomatic congestive heart failure, unstable angina, or serious cardiac arrythmias
Uncontrolled hypertensions defined as sustained blood pressure (BP) \> 150 mmHg systolic BP, or \> 100 mmHg diastolic BP despite optimal antihypertensive treatment
Stroke (including transient ischemic attack), myocardial infarction, or other ischemic event =\< 3 months prior to randomization.
Unstable arrythmia
Thromboembolic event =\< 3 months prior to randomization. Subjects with thromboses of portal/hepatic vasculature attributed to underlying liver disease and/or liver tumor are eligible.
Active bacterial infection requiring systemic treatment. Subjects on prophylactic antibiotics are eligible.
Known human immunodeficiency virus (HIV) infection or known acquired immunodeficiency syndrome (AIDS) related illness. Subjects with known HIV but without clinical evidence of an immunocompromised state and receiving anti-retroviral therapy are eligible
Prior allogenic stem cell or solid organ transplantation
Uncontrolled pleural effusion, pericardial effusion, or ascites requiring recurrent drainage procedures (once monthly or more frequently)
Subjects with indwelling catheters (e.g., PleurX) are allowed.
Uncontrolled or symptomatic hypercalcemia (ionized calcium \> 1.5 mmol/L, calcium \> 12 mg/dL or corrected serum calcium \> ULN)
Uncontrolled tumor-related pain
Patients requiring pain medication must be on a stable regimen at the time of randomization
Symptomatic lesions (e.g., bone metastases or metastases causing nerve impingement) amenable to palliative radiotherapy should be treated prior to randomization. Patients should be recovered from the effects of radiation. There is no required minimum recovery period.
Asymptomatic metastatic lesions that would likely cause functional deficits or intractable pain with further growth (e.g., epidural metastasis that is not currently associated with spinal cord compression) should be considered for loco-regional therapy if appropriate prior to randomization
Other malignancy(ies) =\< 5 years prior to randomization except adequately treated non-melanotic skin cancer, carcinoma-in-situ of the cervix, localized prostate cancer, ductal carcinoma in situ or stage I uterine cancer
Pregnancy or breastfeeding, or intention of becoming pregnant during study treatment or within at least 5 months after the last dose of study medication
Uncontrolled hepatic encephalopathy occurring =\< 6 weeks prior to randomization NOTE: Patients with =\< grade 2 encephalopathy =\< 6 weeks prior to randomization are eligible and supportive measures such as lactulose and antibiotics are allowed