The black keys fill the chromatic half-steps between white keys' whole steps, creating the 12-note octave:
This pattern (groups of 2 and 3 black keys) provides tactile and visual orientation for all 12 pitches, enabling modulation, accidentals, and full harmonic language. Historically, early keyboards had only white keys; black keys were added by the 14th century to accommodate musica ficta.