The correct option is D
He failed multiple times, but he kept trying harder.A simple sentence has only one subject and predicate. It has a finite verb with a completed thought. A compound sentence has at least two parts (also referred to as a clause). Each part has its own subject and predicate and makes good sense by itself. Hence each clause is independent of the other and called the main clause or independent clause. The main clauses are connected using a co-ordinating conjunction (for, and, nor, but, or, yet, so).
A complex sentence has at least one main clause (which is an independent clause) and one or more dependent clauses, connected using a subordinate conjunction. The dependent clause cannot stand by itself and make good sense. It depends on the main clause.
Option A: The two clauses viz (i) "He failed multiple times" and (ii) "He kept trying harder", can stand independently and make good sense. They are independent clauses connected using the co-ordinating conjunction-"but". Hence, this is a compound sentence and this answer is correct.
Options B, C, and D are simple sentences as each of them has only one clause with a single subject and predicate:
OptionB: The subject is "He" and the predicate is "kept trying harder". The words, "Despite failing multiple times" is a phrase and not a clause.
Option C: The subject is "He" and the predicate is "kept failing multiple times". The words, "In spite of trying hard" is a phrase and not a clause. Hence, this is a simple sentence and this option is incorrect.
Option D: The subject is "He" and the predicate is "kept trying harder". The words, "Having failed multiple times" is a phrase and not a clause. Hence, this is a simple sentence and this option is incorrect.