I think the linked question given above mostly answers the question, especially the accepted answer. But I had some additional thoughts that might be useful. I don't know if this will all be strictly correct, but it's what I've gleaned from what I've heard in conversational German. Keep in mind that formal German (for example a newscast or scholarly article) is not the same as conversational German. In conversational language, people tend to go by what "sounds" right rather than keeping track of a list of rules.
There seems to be no strict cutoff for when to use placeholder or not. If it's a simple combination, e.g. Ich lerne Deutsch zu sprechen, you don't need the es or even a comma. More complex sentences would be more likely to use an es. A lot depends on if the main clause would seem ungrammatical without the es. For example in Es ist möglich, kostenlos Sprachen zu lernen, the es is the subject and it would be hard to repair the damage if it was dropped. It depends too on where the es would go in the main clause; if it would be last then it's probably unnecessary.
Note that other placeholders are possible depending on circumstances: Ich dachte daran, eine Sprache kostenlos zu lernen. Here, the dar- part of daran is the placeholder.