This is how I explain it:
"To swim" is the action as a concept. It is something you look towards.
"Swimming" is a reality. Gerund, remember? :) It already exists, and is an actual habit.
So:
"I like to swim" = I like it whenever I can do it. I probably don't have the chance to do it as often as I'd like.
"I like swimming" = I already do this, and I do it often. I enjoy it.