The AMD Ryzen 5 8600G wins in 10 out of 14 comparable specs, with 3 ties. Its biggest advantage is L2 Cache (300% better).
Core i5-9400F wins in 1 spec (MSRP: 31% better).
Recommendation
Choose Ryzen 5 8600G if you want the best overall performance — especially l2 cache.
Choose Core i5-9400F if msrp matters more to you.