Testing the Addition of an Anti-cancer Drug, Pembrolizumab, to the Usual Intravesical Chemotherapy Treatment (Gemcitabine) for the Treatment of BCG-Unresponsive Non-muscle Invasive Bladder Cancer

This phase II trial studies the effect of adding pembrolizumab to gemcitabine in treating patients with non-muscle invasive bladder cancer whose cancer does not respond to Bacillus Calmette-Guerin (BCG) treatment. Chemotherapy drugs, such as gemcitabine, work in different ways to stop the growth of tumor cells, either by killing the cells, by stopping them from dividing, or by stopping them from spreading. Immunotherapy with monoclonal antibodies, such as pembrolizumab, may help the patient's immune system attack the cancer, and may interfere with the ability of tumor cells to grow and spread. Adding pembrolizumab to gemcitabine may delay the return of BCG-unresponsive bladder cancer for longer period compared to gemcitabine alone.

PRIMARY OBJECTIVES:

I. Estimate the 6-month complete response rate of treatment with intravesical gemcitabine hydrochloride (gemcitabine) in combination with MK-3475 (pembrolizumab) in patients with Bacillus Calmette-Guerin (BCG)-unresponsive non-muscle invasive bladder cancer (NMIBC) that have a carcinoma in situ (CIS) component.

II. Estimate the 18 month event-free survival (EFS) rate for all patients with BCG-unresponsive NMIBC receiving intravesical gemcitabine in combination with MK-3475 (pembrolizumab).

SECONDARY OBJECTIVES:

I. To characterize the safety profile of the combination of intravesical gemcitabine with MK-3475 (pembrolizumab) with BCG-unresponsive NMIBC (CIS or high grade Ta and T1 with or without a CIS component).

II. To estimate progression-free survival (PFS) of patients with BCG-unresponsive NMIBC treated with intravesical gemcitabine in combination with MK-3475 (pembrolizumab).

III. To estimate overall survival (OS) of patients with BCG-unresponsive NMIBC treated with intravesical gemcitabine in combination with MK-3475 (pembrolizumab).

IV. To estimate cystectomy-free survival of patients with BCG-unresponsive NMIBC treated with intravesical gemcitabine in combination with MK-3475 (pembrolizumab).

V. To estimate recurrence-free survival (RFS) for patients with a CIS component only and those without a CIS component.

EXPLORATORY OBJECTIVES:

I. To assess correlation between tumor mutation burden (TMB) and EFS and 6-month complete response (CR) rate.

II. To assess correlation between specific genomic alterations (single nucleotide variant \[SNV\] and copy number gains/loss) and EFS and 6-month complete response rate.

III. To assess correlation between APOBEC mutational signature and EFS and 6-month complete response rate.

IV. To assess correlation between immune gene signatures (IGS) and EFS and 6-month complete response rate.

V. To assess correlation between PD-L1 ribonucleic acid (RNA) levels and EFS and 6-month complete response rate.

VI. To assess correlation between RNA molecular subtype and EFS and 6-month complete response rate.

VII. To assess correlation between intratumoral T-cell receptor (TCR) clonality and EFS and 6-month complete response rate.

VIII. To assess correlation between changes in peripheral blood TCR clonality and EFS and 6-month complete response rate.

IX. To assess EFS in patients with urine cell free deoxyribonucleic acid (DNA) (cfDNA) + versus (vs.) patients with cfDNA.

OUTLINE:

INDUCTION: Patients receive pembrolizumab intravenously (IV) over 25-40 minutes on day 1 of cycles 1-4. Patients also receive gemcitabine hydrochloride intravesically on days 1, 8 and 15 of cycles 1 and 2. Treatment repeats every 3 weeks for 4 cycles in the absence of disease progression or unacceptable toxicity.

MAINTENANCE: Beginning cycle 5, patients with no evidence of disease after induction receive pembrolizumab IV over 25-40 minutes and gemcitabine intravesically on day 1 of each cycle. Treatment repeats every 3 weeks for 12 cycles in the absence of disease progression or unacceptable toxicity.

Additionally, patients with T1 tumors undergo a re-staging transurethral resection of bladder tumor (TURBT) within 60 days of registration. Patients also undergo urine and blood sample collection, bladder biopsy, cystoscopy, computed tomography (CT) and magnetic resonance imaging (MRI) throughout the study.

After completion of study treatment, patients with evidence of disease (recurrence or progression) or stop study treatment to receive non-protocol treatment during induction are followed up every 6 months for 5 years. Patients who go off treatment due to any reason other than recurrence/progression or receiving subsequent non-protocol treatment during induction will go to clinical follow-up until evidence of disease progression/recurrence. Thereafter, patients are followed up every 6 months until 5 years from registration. Patients who complete scheduled maintenance treatment according to protocol therapy are followed up every 3 months for 2 years and then every 6 months for 3 years until disease progression/recurrence or receiving subsequent non-protocol treatment. Thereafter, patients are followed up every 6 months until 5 years from registration. Patients who have evidence of disease during maintenance therapy are followed up every 6 months until 5 years from registration.

Eligibility Criteria:
Inclusion Criteria:

* High grade Ta, T1 or CIS urothelial carcinoma. Accrual of patients with Ta or T1 disease may be closed to ensure adequate patients enrollment to meet the primary endpoint
* Persistent disease (defined as not achieving disease free status) after completing therapy with at least induction BCG (\>= 5 doses) and the first round of maintenance or second induction course (\>= 2 doses). The subsequent round of BCG, either maintenance or repeat induction, must be given within 6 months of initial induction BCG
* Persistent high risk NMIBC (T1, high grade Ta and/or CIS) must be within 9 months of the last BCG instillation despite having received adequate BCG as defined above.

  * Registration must be within 12 months of last BCG instillation
* High grade T1 after completing therapy with at least induction BCG (\>= 5 doses) or after completing therapy with at least induction BCG (\>= 5 doses) and first round of maintenance or second induction course (\>= 2 doses). The subsequent round of BCG, either maintenance or repeat induction, must be given within 6 months of initial induction BCG

  * Disease recurrence (T1) must be within 9 months of the last BCG instillation despite having received adequate BCG as defined above
  * Registration must be within 12 months of last BCG instillation
* Mixed variant histology (adenocarcinoma, squamous cell carcinoma) is eligible, but pure variant histology is ineligible
* Patients who are disease free at 6 months after starting BCG but have high grade recurrence (T1, Ta, CIS) while on maintenance therapy would be eligible

  * The recurrence must be within 6 months of the last BCG dose.
  * Registration must be within 12 months of last maintenance BCG instillation
* Patients must be deemed unfit for radical cystectomy by the treating physician or refuse radical cystectomy
* All patients must have histologically confirmed urothelial cancer of the bladder within 60 days prior to registration
* All visible tumor must be completely resected 60 days prior to registration (residual pure CIS is permitted)

  * All patients must have had a cystoscopy (or TURBT with complete resection) without papillary tumor and negative urinary cytology within 28 days of registration (positive cytology is allowed in patients with CIS)
* All patients with T1 tumors must undergo a re-staging transurethral resection of bladder tumor (TURBT) within 60 days of registration

  * There must be uninvolved muscularis propria present in the re-staging TURBT. The initial TURBT prior to re-staging TURBT may be greater than 60 days prior to registration
* Patients must have had imaging with CT or MRI abdomen/pelvis within 90 days of registration demonstrating no evidence of metastasis
* Patients cannot have had a history of urothelial carcinoma in the ureters or prostatic urethra 24 months prior to registration
* Patients must not be currently participating in or have participated in a study of an investigational agent or have used an investigational device within 4 weeks prior to study registration

  * Note: Participants who have entered the follow-up phase of an investigational study may participate as long as it has been more than 4 weeks after the last dose of the previous investigational agent at time of registration
* Patients must not have prior therapy with an anti-PD-1, anti-PD-L1, or anti PD L2 agent or with an agent directed to another stimulatory or co-inhibitory T-cell receptor (e.g., CTLA-4, OX 40, CD137)
* Patients must not have undergone prior allogeneic hematopoietic stem cell transplantation within the last 5 years prior to registration. (Participants who have had a transplant greater than 5 years ago are eligible as long as there are no symptoms of graft versus host disease \[GVHD\])
* Patients must not have received prior systemic anti-cancer therapy including investigational agents within 4 weeks prior to treatment

  * Note: Participants must have recovered from all adverse events (AEs) due to previous therapies to =\< grade 1 or baseline. Participants with =\< grade 2 neuropathy may be eligible
  * Note: If participant received major surgery, they must have recovered adequately from the toxicity and/or complications from the intervention prior to starting study treatment
* Patients must not have received prior radiotherapy within 2 weeks of study registration. Participants must have recovered from all radiation-related toxicities, not require corticosteroids, and not have had radiation pneumonitis
* Patients must not have received radiation therapy to the lung that is \> 30 Gy within 6 months prior to trial registration
* Not pregnant and not nursing, because this study involves an agent that has known genotoxic, mutagenic and teratogenic effects

  * Women and men of reproductive potential should agree to use an appropriate method of birth control throughout their participation in this study due to the teratogenic potential of the therapy utilized in this trial. Include as applicable: Appropriate methods of birth control include abstinence, oral contraceptives, implantable hormonal contraceptives or double barrier method (diaphragm plus condom)
  * A woman of childbearing potential (WOCBP) must not have a positive urine pregnancy test within 7 days prior to registration. If the urine test is positive or cannot be confirmed as negative, a serum pregnancy test will be required
  * Patients must not be pregnant or breastfeeding or expecting to conceive or father children within the projected duration of the study, starting with registration through the last dose of treatment
* Age \>= 18 years
* Eastern Cooperative Oncology Group (ECOG) performance status 0-2
* Absolute neutrophil count (ANC) \>= 1,500/mm\^3
* Platelet count \>= 100,000/mm\^3
* Hemoglobin \>= 9.0 g/dL
* Creatinine =\< 1.5 x upper limit of normal (ULN)

  * In patients with creatinine \> 1.5 x ULN, if measured or calculated creatinine clearance \> 30 mL/min, then patient is eligible
* Total bilirubin =\< 1.5 x ULN

  * In patients with a total bilirubin \> 1.5 x ULN, if direct bilirubin \< 1.0 X ULN, then patient is eligible
* Aspartate aminotransferase (AST)/ alanine aminotransferase (ALT) =\< 2.5 x ULN
* Patients must not have had an active autoimmune disease requiring systemic treatment within 24 months prior to registration. Autoimmune diseases include, but not limited to, lupus erythematosus, rheumatoid arthritis, inflammatory bowel disease, antiphospholipid syndrome, Wegener's granulomatosis, Sjogren's syndrome, Bell's palsy, Guillain-Barre syndrome, multiple sclerosis, autoimmune thyroid disease, vasculitis, or glomerulonephritis
* Patients must not have a diagnosis of immunodeficiency or is receiving chronic systemic steroid therapy (in dosing exceeding 10 mg daily of prednisone equivalent) or any other form of immunosuppressive therapy within 7 days prior to registration

  * Note: Replacement therapy (e.g., thyroxine, insulin, or physiologic corticosteroid replacement therapy for adrenal or pituitary insufficiency) is not considered a form of systemic treatment and is allowed
* Patients must not have a known psychiatric or substance abuse disorder that would interfere with the participant's ability to cooperate with the requirements of the study
* Patients must not have active tuberculosis
* Patients must not have been treated with antibiotics for an active infection within 14 days prior to registration. Prophylactic antibiotics are permitted. Treatment for a urinary tract infection (UTI) is allowed but must be deemed adequately treated by the treating physician prior the start of cycle 1 (C1) day 1 (D1)
* Patients must not have a history of idiopathic pulmonary fibrosis or organizing pneumonia
* Patients must not have a history of (non-infectious) pneumonitis that required steroids or have current pneumonitis
* Patients with human immunodeficiency virus (HIV) are eligible with the following:

  * On effective anti-retroviral therapy with undetectable viral load within 6 months of registration
* HIV-infected participants must not have a history of Kaposi sarcoma and/or multicentric Castleman disease
* Patients must not have a known additional malignancy that has had progression or has required active treatment in the last three years. Exceptions include basal or squamous cell carcinoma of the skin that has undergone potentially curative therapy or in situ cervical cancer. A history of prostate cancer that was treated with definitive intent is allowed, provided that the prostate-specific antigen (PSA) is undetectable for at least 1 year while off androgen deprivation therapy
* Patients must not have known active CNS metastases and/or carcinomatous meningitis. Participants with previously treated brain metastases may participate provided they are radiologically stable, i.e., without evidence of progression for at least 4 weeks by repeat imaging (note that the repeat imaging should be performed during study screening), clinically stable and without requirement of steroid treatment for at least 14 days prior to first dose of study treatment
* Patients must not have severe hypersensitivity (\>= grade 3) to pembrolizumab and/or any of its excipients
* Patients must not have an active infection requiring systemic therapy
* Patients must not have a known history of hepatitis B (defined as hepatitis B surface antigen \[HBsAg\] reactive) or known active hepatitis C virus (defined as hepatitis C virus \[HCV\] ribonucleic acid \[RNA\] \[qualitative\] is detected) infection

  * Note: No testing for hepatitis B and hepatitis C is required unless mandated by a local health authority
* Patients must not have received live vaccines within 30 days of study drug administration. Examples of live vaccines include, but are not limited to, the following: measles, mumps, rubella, varicella/zoster (chicken pox), yellow fever, rabies, Bacillus Calmette-Guerin (BCG), and typhoid vaccine. Seasonal influenza vaccines for injection are generally killed virus vaccines and are allowed; however, intranasal influenza vaccines (e.g., FluMist®) are live attenuated vaccines and are not allowed. COVID-19 vaccinations are permitted