Paying rent in cash is legal.
If you pay rent in cash just make sure you get a receipt for payment of rent.
Because without the receipt when you pay rent with cash there's no proof you paid the rent.
So always get a receipt when paying rent with cash.
I've paid rent with cash before and never had any issues as I always made sure to get a receipt in case something came up.
Other times I've paid rent with a check or money order.
But some landlords may only want cash for rent which okay.
If the landlord won't provide a receipt for the cash rent payment then I would look elsewhere for a place to rent.
Also always get a lease as well.
People have been paying rent in cash legally for a very long time.