Hi Ken,
It's purpose is to prevent moisture (from your body) from penetrating the foam and reaching a cooler, solid surface and condensing out as liquid water.
It's particularly important that it be in your mattresses. We had the foam in our V-berth mattresses replaced a few years back and the installer missed replacing the plastic in only one mattress ( mine of course) and the foam was soaked after a few days of use. The V-berth sits over the potable water tank which is cold.
I used dry cleaning film (very thin polyethylene) to line the upper surface of the mattress. You could use a thicker poly film but it crackles every time you move.