Imagine a time where black keys were cheaper to make, which is probably why harpsichords and older fortepiano used to have black "white keys" and white "black keys" (see picture in this article).
As @Divizna commented, "most human history didn't have 100W lightbulbs." If every key were black, it would be harder to orient yourself while split-second peeping at the keys before the occasional jumps in the music that are farther than an octave, even though as you said, seasoned players look mostly at the score, not at the keys.
If cost was no longer the reason, why then the color scheme was switched? The above cited article advanced this reason:
It was also suggested that the black keys on the piano made it difficult to detect the spaces between the keys. This, in turn, led to difficulty in telling the exact locations of the keys. By switching the colours, the black spaces became highly visible and playing became easier.
If the only requirement is so the dark lines between the keys are visible, in the age where smartphones have fashionable colors (like these iPhone 15 color options), why not make all keys (including the black keys) white or tinted with light colors such as light grey, light yellow, or light pink? Maybe someday piano makers will do that, instead of simply changing the wood finish color (example: white, gold leaf, pink). I would think having light monotone color for all keys would be fine, even for beginning students, but going to extreme by removing all black keys is a no go, despite the effort to modify a piece like Doctor Gradus ad Parnassum works by using only white keys. At least that experiment shows how a seasoned pianist can manage to play a relatively complex piece without mistake when 1) all keys are white, 2) have exactly the same shape, and 3) there's no marking where the middle-C is. We can still clearly see the gap between these all-white-keys piano. Adding back the "black keys" in the white color would make that piano even more functional and easier to play.