Code files become unmaintainable (try searching in them!) after a few hundred lines. Some people go up to a few thousand (but this is already a problem). Even small projects have thousands of lines, medium projects have tens of thousands of lines, and big projects have millions of lines. Text editors cannot cope with files this big (but programmers themselves cannot either).
Splitting a project into different source files is also necessary if you want to separate your project into different compilation units, which makes compilation much faster because only parts of the projects need to be recompiled.
A few decades ago programs used to be written in one single file / stack of cards. However, these programs were tiny in comparison to modern programs, and completely unmaintainable – even small changes essentially necessitated a rewrite, which put a fixed upper limit on the complexity that could thus be achieved.
Modern, more complex projects essentially require splitting apart. The question of putting everything in one file is frankly one that I’ve never asked myself because the idea is simply inconceivable.