Freshwater single-celled organisms have a big problem in terms of the osmotic gradient. The inside of the cell has a certain osmolarity that is higher than the surrounding water, which causes free water to be drawn into the cell. If this continues and isn't compensated for, the cell will swell and burst! So, the organism needs to have a mechanism to expel free water with a minimal amount of solutes to keep the internal osmotic pressure. That mechanism is the contractile vacuole.
We don't have a great understanding of the full mechanics of how these vacuoles work, but they appear to pump ions into themselves to create another osmotic gradient between themselves and the cytoplasm. This allows free water to diffuse into the vacuole from the cytoplasm. The vacuole then contracts to expel water from the cell.