It was a mistake for us to come here tonight.
It was a mistake [for us to come here tonight].
"For" has no meaning here. It's a subordinator marking the start of the bracketed non-finite clause.
Where a to-infinitival clause contains a subject, it also contains the meaningless clause subordinator "for", which appears at the beginning of the clause, right before the subject, in this case "us".
Briefly, the history of "for" goes back to the preposition "for", but this "for" behaves as a clause subordinator.
Other examples include:
[For John to lose his temper like that] is very unusual.
We can't afford [for everyone to travel business class.]
For in this sentence has no meaning; it's part of a larger construction, the for...to complementizer that introduces infinitive clauses. There are two parts to the complementizer -- for marks the subject of the infinitive clause, if it's present, and to marks the verb phrase of the infinitive clause.
- For [him] to [leave early] would be a good idea.
In the sentence above, him is the subject of leave early, and the infinitive clause for him to leave early is the subject of would be a good idea. Infinitives are always subordinate clauses, and they're non-finite (they're not inflected for past or present tense), and they are very common in many constructions.
The complementizer for is usually not present in most infinitives; it's required when an infinitive clause with a subject begins the sentence, as above. But if you extrapose that infinitive to the end and leave a dummy it behind, you get
- It would be a good idea (for him) to leave early.
the for him subject can be deleted, as infinitive subjects often are
- It would be a good idea to leave early.
The to doesn't have any meaning, either; they're both just part of the machinery.