It is better to underestimate your abilities and overestimate your risks than to go in a direction that actually involves more uncertainty than you can justify.
This sentence uses a special structure called an extraposition. We don't generally like to use infinitival clauses as Subjects because they are hard for our listeners to process:
- [To do the right thing] is hard.
Instead we use a dummy pronoun, the word it, as a Subject, and move ('extrapose') the old subject to the end of the clause:
- It is hard [to do the right thing].
This sentence means the same thing as the one further above.
The Original Poster's sentence also uses an extraposition. It means:
- [To underestimate your abilities and overestimate your risks] is [better than [to go in a direction that actually involves more uncertainty than you can justify]].
The syntactic function of the second infinitival clause here is Complement of the preposition than. Remember that by 'syntactic function' we are talking about jobs like Subject, Object, Complement and so forth. The preposition phrase than to go ... certainty is itself the Complement of the adjective better.
In terms of what type of phrase/clause it is, it is a comparative clause, as opposed to a content clause or relative clause. This means that it contains gaps and reductions from which the listener subconsciously reconstructs the full meaning of the clause. For example, this clause has an ellipsis at the end:
- [X] is better than [Y ______ ].
We can reconstruct that ellipsis roughly like this:
- [X] is better than [Y is good].
Here better obviously means more good, so it may help to think of it like this:
- [X] is more good than [Y is good].
The clause to go in a direction ... justify is a comparative clause functioning as Complement of the preposition than.
Because this clause is the Complement of a preposition, some grammars call it an NP. However, this does not really tell you what kind of chunk of words it is. It just tells you what syntactic function that chunk of words might be doing in the sentence (i.e. it is just saying it is doing one of those jobs often done by phrases headed by nouns). For example, calling it an NP will not tell you that this chunk of words has obligatory gaps in it.