'To' is not a preposition here; it is the infinitive particle. 'To do so' is a nonfinite clause post-modifying 'failure' (a noun), so the whole thing ('a failure to do so') is a noun phrase.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.