Benefit from using 3400 MHz RAM on a CPU that's only rated for 2400 MHz RAM
Solution 1:
Higher-frequency RAM is often via an overclocked profile (e.g. XMP) which you have to enable in the firmware settings. The only real downside is higher power consumption and a bit more heat if you enable it. Compared to buying lower-frequency RAM, you're getting a guarantee that your memory will be able to overclock to those frequencies, and a built-in profile that makes it effectively a one-click operation.
Note that the "2400 MHz" is just the standard memory frequency; it will go higher if you use the XMP profile (or manually overclock).
Worst case? You pay a bit more for the RAM but run it at the lower speed. No big deal.
Solution 2:
I would add to Bob's answer that frequency of operation is not the only thing that determines memory performance. Latency is another big part of it.
Latency is governed by the frequency and the timings together. Buying a high-frequency memory module, you can operate it at a lower frequency and tighten the timings to achieve better latency. (Or vice versa to achieve more bandwidth with worse latency)
This procedure is still similar to overclocking and has to be done manually, but there are many guides on how to achieve this.
This procedure can make high-frequency memory operated at a lower frequency be worthwhile in the extra payed for the higher frequency.
Solution 3:
Although timings and latency are the main benefit (as other answers state), there is one other benefit worth mentioning, which is that you may be able to undervolt as well/instead.
Why would this matter?
The power and voltage requirement of RAM is typically dependent on how hard it's driven. Like some other components, if you want more performance you need to provide a bit more voltage and power.
Now, suppose you buy some RAM rated at 3400GHz but you only plan to drive it at 2400. From the RAM's perspective you are running it at reduced performance. It doesn't need to do so much per second, electrically and in terms of switching. So if the RAM is rated as needing (say) 1.2v you might be able to run it stable at 1.05 -1.10v. That might be all you need to use it with the next generation of CPUs and not have to buy new (or if the necessary RAM isn't quite available yet).
Case in point - my old Ivy Bridge Extreme (i7-4960X) should be run using 1.5v RAM voltage, plus maybe 5% or 10% tolerance. Say 1.57v ideally max. It's hard to know if more would do damage and there are many web pages debating it, but that's a side-issue here. Suppose you wanted to run it in tolerance. The problem is, at that time you couldn't get matched 8-DIMM 1.5v sets for 64GB, or if you could, it ran at 1600 or 1866 or something, because 1.5v was newish. The 64GB kits that were closest and would do 2133+ required 1.65v. By buying one of those and running at a slightly lower speed than its rated 2400, I was able to get it stable on 1.53v which gave me what I actually wanted - and I also made up on performance because I could tighten the timings as well.