
The bells would be arranged and tuned to play very simple melodies in modes and scales with few notes, where the ringing overtones of the bells would not clash with each other too much. It was not possible to damp each bell, or to restrict the length of the sounding of each note each bell continued to ring out after it was struck. The "keys" were large heavy foot- and hand-operated levers that triggered ropes that rang bells, and required the performer to throw their body weight onto each lever. The keyboard first evolved to play arrays of church bells. Elucidating "why" is a murky question at best. Going back to antiquity, things always evolve the way they do because over the centuries people find it the most practical and popular method. Would often include B♭ and B♮ both as diatonic "white notes," with theī♮ at the leftmost side of the keyboard and the B♭ at the rightmost. In Gregorian chant (the seven diatonic notes plus B-flat) and as such The earliest designs of keyboards were based heavily on the notes used Wikipedia mentions the Gregorian Chant influence of early keyboards but doesn't get into details on how/why they evolved to the modern piano layout:

However I haven't found a reliable source confirming it.

Some websites state that the reason is Gregorian music since they only used their modes (which only included pitches from the modern C diatonic scale) and then the black keys were added. What's the cause/history of the asymmetrical layout of the piano keyboard? The asymmetrical way in which the black and white keys are placed makes it hard to transpose music and learn scales, since the same scale has a different layout when played in a different musical key. The piano keyboard has white keys based on the C Diatonic scale plus black keys, which add the remaining notes used in western music.
