Most German sentences need a subject. The most significant exception is subjectless passive sentences (for example: Heute wird gefeiert) but unless you are dealing with passive it is a good idea to assume you always need a subject.
In the sentence about snowing, the verb schneien in active voice needs a subject. Since there is no other part of the sentence that carries meaning and could take over the subject role – die ganze Nacht is a temporal adverbial and heftig is an adverb – some agent needs to come in and stand in as subject. This is an expletive, the word es. As the role of this word is to be subject, it cannot be left out when reordering the fragments of the sentence because otherwise a subject would be missing.
The sentence about talking to people is somewhat more complicated. In its original form, I would classify the fragments as follows:
Manchmal (adverbial) ist (finite verb; here: copula) es (subject) schwierig (predicative adjective), mit unbekannten Personen ins Gespräch zu kommen (extended infinitive postfixed).
The entire part behind the comma could be considered as a subsentence of its own. Just add a subject and conjugate the verb and voilà. If you intend to keep all these fragments as what they are, then the es will have to remain. For example:
Es ist manchmal schwierig, mit unbekannten Personen ins Gespräch zu kommen.
However, depending on the requirements of the exercise it may be permissible to also relabel parts of the sentence. Instead of having starting a conversation with unknown people as a single, immobile postfix, you can:
Turn the infinitive (as a whole) into a subject (instead of saying it is difficult you are saying talking is difficult):
Mit unbekannten Personen ins Gespräch zu kommen ist manchmal schwierig.
(Note the absence of a comma here; although it is allowed, I wouldn’t place it)
Obviously, if you have a different subject, the es must leave.
Split apart the extended infinitive; carrying the unknown people into the main clause:
Mit unbekannten Personen ist ins Gespräch zu kommen manchmal schwierig.
Ins Gespräch zu kommen ist mit unbekannten Personen manchmal schwierig.
When the extended infinitive is split apart, the shorter infinitive which relies on the unknown people can no longer be its own postfixed infinitive. Instead, it must now directly contrast with schwierig – but since that is a predicative adjective and the verb is the copula, it becomes clear that ins Gespräch zu kommen must now be the subject (mit unbekannten Personen while somehow still being a prepositional object to the talking can now be regarded as an adverbial of the main clause).
As an undeniable subject exists, an es would be superfluous.
These juggling exercises are complex, especially when relabelling fragments is possible as in the extended infinitive case. Depending on the requirements of your exercise some of my examples may and some may not be possible. One day, you will hopefully reach a level when your brain just gives you the correct answer automatically, without you thinking – like native Germans.
*asterisks*
. Do you have any example exercises where you wouldn’t need an »es«?