I am deciding which parts to include in my PC, primarily aimed towards gaming. My last PC lasted 7 years so longevity is the key for this build. Obviously no one can know the future so I'm just looking for more experienced guesses. Right now the difference between the 9th generation i5,i7,i9 is measly. However, from GCSE computing science I know that programs have to be coded to use cores. So in future will more cores become more common? Or will the difference between six and eight cores remain negligible especially when in the context of VR. Also to clarify, will the i5-9600k's relative performance decline in the next 4/5 years faster than the i9-900k?
Will the i5-9600K's relative performance decline in the next 4/5 years faster than the i9-9900K?
Both of these CPUs will always be more than enough for general computing needs over the next 5 years.
If you look at some FPS benchmarks to compare the i9-9900K and i5-9600K you might see that the i9 has a small FPS advantage over the i5. That advantage really comes from the slightly higher clock speeds (5.0 Ghz vs 4.6 Ghz). The extra cores on the i9 can't really be utilized to increase FPS further, and it is unlikely that games will be requiring more than 6-8 cores in the next 5 years. VR is pretty much the same CPU workload as gaming but with a higher desired FPS, so everything said next about gaming applies to VR too.
You will have a good, lasting CPU for gaming if you buy the i5-9600K. There are reasons to consider the i9 for use-cases other than gaming though!
So why don't more cores help? Will they ever help?
In computer science, we use a phrase, "Divide and Conquer" to describe algorithms that can break up a large task into many independent tasks. Tasks like encoding videos, compressing files, updating thousands of database rows, etc. can be accomplished using a "divide and conquer" algorithm that breaks up the data into isolated sections and processes them in parallel on as many cores as possible. This is the sort of CPU workload where CPUs with lots of cores shine, and unfortunately games just don't fall under the criteria for "divide and conquer".
Games and real-time simulation are the sort of program that requires gamestate A to be computed before starting gamestate B, and so on. This is accomplished with a loop, and every frame or update is an iteration of that loop. You may already know that loops execute on a single thread, which means only one core in the CPU is really "in charge" of the entire game. The maximum rate at which this loop can execute is the max speed of the game engine, and this is why higher clock speeds lead to higher FPS.
There are ways to break off some of the workload from the master thread though. For example, AI doesn't need to make decisions every frame; Resources like textures and models can be loaded in the background and used when they're ready. Even newer graphics APIs like Vulkan and DX12 allow the GPU to be commanded from multiple threads. These kinds of tasks can be offloaded to the extra cores, but they usually aren't algorithms that completely utilize a core (they sleep while waiting for files, network, etc.) Which means several threads spun up for side-jobs are able to share just a few extra cores.
Lastly, you can usually gauge the next 4-5 years of gaming requirements by what the current/next generation of game consoles are using. The next XBox and Playstation are expected to have 8C/16T CPUs so you certainly won't need more than 8 cores to keep up with the next generation of games. But keep in mind the current generation of consoles had reserved a number of cores for the OS, and are now also capable of live-streaming, installing games, and other background tasks that require the CPU while gaming.