OK, first let's take a look at what some grammar books say, then try to make it comprehensible with some examples:
CGEL says:
The infinitival is more associated with change, the gerund-participle with actuality. Thus someone who has recently turned forty or got married might say "I like being forty" or "I like being married". An infinitival would be strange here, suggesting repeated changes from not being forty or married to being forty or married. In this case the meaning is close to that of "enjoy", which only allows gerund-participles.
Quirk et al. say:
With the verbs which take both constructions the bias of the infinitive towards ‘potentiality’ tends to favour its use in hypothetical and nonfactual contexts; on the other hand, the participial construction is favoured when the speaker is referring to something which definitely happens or has happened.
More simply (if less precisely) the gerund-participle ("-ing" form) is used when the pleasure is derived from the action itself, whereas the infinitive ("to" form) is used when the preference is being expressed for choosing to perform the action, or the idea of the action, as distinct from the action itself.
Quirk gives the following examples:
(OK:) Would you like to see my stamp collection?
(Very odd:) Would you like ?*seeing my stamp collection?
(Questionable:) Brian loathed ?to live in the country.
(OK:) Brian loathed living in the country.
The question "Would you like seeing my stamp collection" is odd, because presumably the person being asked hasn't seen it, and doesn't know whether they'll enjoy the experience—but asking "...like to see..." is asking whether they'd appreciate the opportunity to do so—the idea of doing so. By contrast, "living in the country" is preferable because it is the experience of life in the country that Brian finds objectionable.
As for CGEL's samples: the contention is that it's preferable to say "I like being married" and "I like being forty", except in certain (very odd) circumstances. This is because the use of the infinitive implies that there is a choice going on—whereas, once you're forty, you keep being forty (well, for the next year, anyway), and similarly you tend to keep being married (divorce takes a long time!)
That said, someone like Elizabeth Taylor might well have said "I like to be married", given that she did it lots of times...
Giving another example: I might say "I like to run every morning", which means roughly "It makes me happy to choose to organise my life in this way". But saying "I like running every morning" implies that it's the actual running itself that gives me the pleasure.