In Classical antiquity swimming and bathing was most often done nude. In some settings coverings were used. Murals at Pompeii show women wearing two-piece suits covering the areas around their breasts and hips in a fashion remarkably similar to a bikini of ca. 1960. After this, the notion of special water apparel seems to have been lost for centuries.
In various cultural traditions one swims, if not in the nude, in a version in suitable material of a garment or undergarment commonly worn on land, e.g. a loincloth such as the Japanese man’s fundoshi.
The invention of the railway, and the proliferation of rail travel in the mid 1800s made it possible for large numbers of people to visit coastal regions. In the 18th century women wore “bathing gowns” in the water; these were long dresses of fabrics that would not become transparent when wet, with weights sewn into the hems so that they would not rise up in the water. The men’s swim suit, a rather form-fitting wool garment with long sleeves and legs similar to long underwear, was developed and would change little for a century.
In the 19th century, the woman’s two piece suit became common—the two pieces being a gown from shoulder to knees plus a set of trousers with leggings going down to the ankles.
In the Victorian era, popular beach resorts were commonly equipped with bathing machines designed to avoid the exposure of people in swimsuits, especially to people of the opposite sex.