Hi the rubber diaphragms dose two things i think.
One it stops fluid leaking out and it also stops air which has water vapour in it getting in.
the rubber is that shape because the brakes are a sealed system and when the pads wear more fluid is needed in the callipers to posh the piston out. If the top dose not let air in it will make a vacuum and stop the fluid moving making the brakes useless so the rubber is shaped to take up the space the fluid once occupied.
Above the rubber the cap has a small breather hole to let air in and the rubber keeps the fluid separate from the air.
Brake fluid is hygroscopic and will absorb water. If water is in brake fluid and gets hot it can boil and make bubbles and brakes will feel like they need bleeding and spongy.
A bit long winded but I think this is right
best get a new one if you can if nothing else it keeps fluid of your paint
hope you get back on the road soon