Generally speaking, the i5-8400 is better than the i3-8100. The i5 has 6 cores instead of 4 cores and the clockspeed can go as high as 4.0GHz vs. 3.60GHz.
The slightly higher clockspeed can provide slightly better FPS in games that are CPU dependent, but in games that are not CPU dependent, then there is no discernible difference in performance... unless getting 1 FPS less really pisses you off. Having more cores is better than having fewer cores, but games need to be designed to take advantage of those cores. If a game can only make use of 4 core or less (the vast majority of games in general still use 2 cores), then it doesn't matter very much if the CPU has 4, 8 or 12 cores.