The only complement this kind of "do" accepts is an active verb phrase (headed by a verb of action) with zero infinitival inflection. To the question "What can I do?", thus, you may answer "You can tell them the truth" or "What you can do is tell them the truth", or simply "Tell them the truth", BUT NOT "*To tell them the truth", which is a CLAUSE with a generic, invisible subject, NOT just a verb phrase. What complicates matters in cases like the one you ask about is that either a verb phrase or a clause can, depending on the subject, function as the attribute of "be" [identity-be: A is B = A is the same as B]. Hence, the sequences "is to tell them the truth" = [BE+ Clause] and "is tell them the truth" = [BE + VP] are both well-formed in themselves. Whether they eventually yield a grammatical sentence depends on the choice of an appropriate subject. You need a subject that can satisfy identity with respect to the clause or the verb phrase, respectively. In the example you mention the subject is a noun phrase ("The only thing to do" = “The only thing that one could do”) containing a reduced relative clause "[zero relative] to do _" whose invisible complement must be a verb phrase, as explained. Now, the antecedent of the relative (“the only thing”) must, by definition, also be a possible object of “do” (= an x such that to do x is the only possibility). That guarantees a legitimate identification between “the only thing to do” and what follows identity-be, i.e., “ask them to come half an hour later than the other guests” and the correctness of the sentence. Why can “to” (= the clause) appear as well, in this case? Well, because “thing” can ALSO refer to a complete event/state of affairs, cf. “There is one thing/something you do not know: I resigned this morning / I am married”. If instead of a noun phrase the subject is a free relative clause “What we can do”, there is no antecedent (no “thing”), and only something that can be the complement of “do” (and co-referential with “what”) can follow identity-be: “What we can do is ask them to come <….> guests” is correct, but “*What we can do is to ask them to come <…> guests” is not. In that case, there is no optionality: “to” is not possible.