The Intel Core i9-10900K wins in 7 out of 14 comparable specs, with 4 ties. Its biggest advantage is Threads (233% better).
Core i5-8400 wins in 3 specs (Max Turbo Power: 74% better).
Recommendation
Choose Core i9-10900K if you want the best overall performance — especially threads.
Choose Core i5-8400 if max turbo power matters more to you.