Here are a couple thoughts on the “why the notes are what they are” of the pentatonic scale.
First, the major pentatonic scale is the intervals which are valid over all three of the major chords contained within the structure of the major scale. For example, in the key of G the major chords are G, C, and D. The C has a different “fourth” and the D has a different “seventh” than the G. That’s why the major pentatonic scale doesn’t have the fourth or seventh. The minor pentatonic scale is the intervals which are valid over all three of the minor chords contained within the structure of the major scale. In that same key of G the minor chords are Em, Am, and Bm. The Am has a different “sixth” and the Bm has a different “second” than the Em, so the minor pentatonic scale does not have a sixth or a second. It is for this reason that the pentatonic scale is super useful for visualizing the fretboard- if you can remember the pentatonic shapes then you can easily see/imagine all of the diatonic major and minor arpeggios in every scale position.
Second, the pentatonic scale is what it is because it is the intervals which give you the most power with the most simplicity. imagine how difficult it would be to improvise awesome solos or to write a lot of compelling melodies with just the notes of one basic chord, such as the minor seventh chord. Wouldn’t it be so hard to avoid being boring, and having everything you play sound the same? I couldn’t do it! However, if we add just one note then a magical thing happens. That one extra note lets you have great creative power, enough to write big hits in every genre. The minor pentatonic scale is exactly this: it’s a minor seventh chord with one extra note.
Third, the pentatonic scale is what it is because people just love the sound of vocal melodies that are built on it. Probably the most important thing that I ever did to improve my knowledge of music was when I made a list of about a hundred of my favorite vocal melodies and started transcribing them. It turned out that my favorite vocal melodies are all either heavily based on the core major/minor pentatonic scale or the natural minor’s “minor add 9” arpeggio. If you want to study some good use of the pentatonic scale outside of a guitar context, Katy Perry is brilliant. It’s not an accident that she’s one of the best-selling artists of my life. Start with “Hot N Cold” if you’re interested.
Quick side note: the pentatonic scale is popular with keyboard people ‘cuz the black keys are a pentatonic scale. You just transpose the keyboard to whatever key you’re in and write your melodies with the black keys and then people give you money.