Since pitot static systems are open the outside, how does the system remain clear of water or other contaminants?
In addition to drains on the pitot tube itself some aircraft have separate "drip chambers" and drains for the pitot (and occasionally static) system to remove condensation or rain that got past the drains (marked as
2 in the photo below):
Regarding other contaminants, at altitude the air is generally pretty clean.
The biggest problem you'll have with contaminants in the pitot tube is usually bugs (either building a nest in the opening, or smacking into it in flight). Pitot covers can be used on the ground to prevent this (and they're also used when washing or painting aircraft to prevent water or paint from getting into the system). Often some tape serves the same purpose - but you need to be sure to remove the tape or cover before flying.