Of course it doesn't cost *nothing* but it costs very little - the water isn't free (people will splash out some water) and the chemicals to keep the water clean-ish isn't free (people will dirty the water). In fact, it costs exactly the same, per swimmer, as it does during the day and that is where the problem really is. In addition to that, if the word spreads you allow semi-illegal free night swimming, it is very reasonable that some of the people who would swim (and pay) during the day will choose to swim for free at night, bringing no income to you and only cost. And then on top of it all, if the number of night swimmers really increases, people might conclude that they are entitled to pool guards, working drink bars, etc., which would, even if possible, require hiring night staff which would probably cost more than day staff.
Personally, I don't think this can be "solved" or, really, that there is anything there to "solve". It is human nature to want things for free. It is probably a property of every living thing. The only practical option is to have some kinds of artificial rules that would guard a balance between total anarchy and total capitalism. Thus, most people choose some brand of doublethink - "stealing is bad, but I'm still a good person if I don't steal too much."