When I was first asked this question I almost laughed; it seemed like such a simple question. Then when I started to think of the answer I realized it was much more complex than I initially thought; so here is the answer for you!
The most important reason is, if you had all white keys, it would simply be impossible to find your place on the keyboard – you would have to start at the bottom and count up all the keys to find a specific note! The black keys create a simple visual cue, a repeating pattern of groups of 2 black keys and 3 black keys which help you find your place on the keyboard.
However, keys aren’t simply laid out in order of black and white without meaning; there is a basic logic behind the layout which reflects the basis of major/minor tonality. When it comes to pitch, the distance between all adjacent keys on the piano– from black to white, white to black and where they occur, white to white – are all the same; they are all half-steps apart.
But what is the significance of the pattern of black keys relative to white keys? The white keys of the piano form a C major scale! It is a series of whole steps (2 keys together, one key between) and half steps (2 keys together, no keys between) in which they are all whole steps except between the 3rd and 4th notes (E and F), and the 7th and 8th notes (B and C). So when you play all the white keys from C to C you are playing a C major scale!
You can play in any key on the piano by utilizing specific black keys when playing in any key other than C major. This is reflected in key signatures, a topic for another video for you!