The diatonic scale is one of many scales called rank two temperaments, a very important concept in the way we tune instruments. What this means is that two intervals are used to generate the entire scale, one used as the period, which is the octave. What this means is that a high D and a low D, or any other versions of the same note, will both be included in the scale if one of them is, the scale repeats.
The other is the generator, which generates every other interval of the scale, and is stopped after however many notes is desired. Now this is three variables that can be changed to whatever we want, so how should we choose? Well, the first two are intervals, and some intervals are much more consonant than others, the two most consonant generally considered to be the octave, or 2/1, and the perfect fifth, or 3/2. Using the first as the period and second as the generator creates a scale that maximizes the number of perfect fifths, and as such maximizes consonance to a certain degree. No matter how many notes are used, each note but one will have a perfect fifth above it.
So how many notes should be used? If we want a scale with only two kinds of steps, the two options would generally be 5 notes and 7 notes. 5 notes has the advantage of including little to no dissonance, and is known as the Pentatonic scale. However, the 7 note version has a different strength, and it lies in the fact that perfect fifths can generate other intervals. Two more intervals that are well known consonances are 5/4, or the major third, and 6/5, or the minor third. These intervals sound consonant yet colorful, unlike the largely colorless octave and fifth. When you use pure perfect fifths to generate the scale, which is known as the Pythagorean scale, four fifths approximate 5/4 decently well and three upside down fifths going down approximate 6/5 decently well. 7 notes allows every note to have either a major third or a minor third above it, giving each mode of the scale its own flavor.
The pythagorean scale, however, has not been in common use since the medieval era, as we have found that flattening each perfect fifth every so slightly can improve the thirds to a great degree, with the amount differing depending on how one would desire the thirds to sound, collectively called Meantone temperaments. Quarter-Comma Meantone, for instance, tunes the major third purely. 12 tone equal temperament includes a fifth that is flat by an unnoticeable amount, so the fifths all sound good and the thirds are better than pythagorean, though other equal temperaments include different fifths, and as such, different diatonic scales. Fifths of size between 4 steps of 7-ET and 3 steps of 5-ET generate diatonic scales, but fifths that are flatter or sharper can generate interesting scales as well. A fifth around 9 steps of 16-ET, for instance, generates mavila, with similarly tuned thirds but wildly different step sizes. You can explore the scales of other equal temperaments on your own, microtonality really is a very interesting world.
Rank two temperaments, however, are not the only type of temperament, and one very significant variant of the diatonic scale is based in Just Intonation instead, where every note is based on an exact frequency ratio. This is called the Intense Diatonic scale, Zarlino scale, or Ptolemy scale. It has more than two types of step sizes, and only five notes have a perfect fifth above them, as opposed to six, but the other ratios such as major and minor thirds are tuned purely without compromising the majority of the fifths.
This system is hard to expand to an entire 12-tone system, though certain tuning schemes such as the Asymmetric Scale, Centaur, and Kirnberger I attempt it, and instruments such as the Kalimba that often only include seven notes work quite well with the Ptolemy scale. ET systems such as 15 and 53 tone equal temperament include approximations to this Ptolemy scale, but not a meantone one (though 53 contains Pythagorean), so they take advantage of its alternative approach to the diatonic scale. These scales are not intrinsically connected to an equal temperament however, and they are just a few out of many ways to map the tonal space, so try some other temperaments out! Some of my personal favorites are Orwell9, Blackwood, and Mavila.