In 1719 Bach visited Berlin on an errand. It is there that he met Christian Ludwig, Margrave of Brandenburg. The following year Bach's first wife (Maria Barbara) died; shortly thereafter, Bach found that retaining his position in Cöthen was losing its appeal, for a number of reasons, among which, reportedly, is Princess Friderica's displeasure for Bach's music. (Friderica was the new wife of Bach's employer, Prince Leopold.)
Perhaps as a plea for employment, Bach collected a group of his works, and sent the score entitled "Six Concertos for Several Instruments" to Christian Ludwig. Whether Christian Ludwig responded or not is not known, but we do know that Bach did not move to Berlin for his next position.
Because the collection was dedicated to the Margrave of Brandenburg, these works are generally referred to collectively as the "Brandenburg Concerto". They otherwise have little in common. the instrumentation, keys, and themes change from one concerto to the next.
There are, nonetheless, certain similarities which arise from their being concertos by the same composer. Among Bach's influences in instrumental writing were a group of Italian composers who were Bach's approximate contemporaries (or very near predecessors, separated by very few years), including (most especially) Vivaldi. We know that Bach studied Vivaldi's concertos, because he re-scored some of them himself. From Vivaldi and other Italian composers Bach learned the concerto grosso format, where a large ensemble (tuti, or ripieno) alternates with a soloist or solo group (concertino). This creates contrasts in texture, dynamics, and sometimes melody. The ripieno plays the opening section, which establishes a recurring theme (ritornello) for the movement. The episodes which fall between statements of the ritornello are performed by the concertino; these passages are more virtuosic, and may sound improvised, even when they are written out. Often, the melodic material comprising the episodes is based on motives from the ritornello, but after a short time, the theme is developed in a new direction.
Brandenburg Concerto No. 5 in D major is scored for flute, solo violin, obbligato harpsichord, and strings. It is interesting to note that in the ripieno, Bach writes only one violin part, rather than two, as is generally his norm. The harpsichord is given special prominence in this concerto, being elevated from its usual role to serve the supportive capacity, as well as being the unifying timbre throughout the work (the harpsichord is always present) and - most importantly - it accepts a virtuosic position as a featured soloist. This may be the first time that the harpsichord was treated as a soloist. The concerto is set in a typical fast-slow-fast arrangement. The opening allegro is the longest among all movements of the six Brandenburgs.
The opening theme is an example of the kind of theme known as Fortspinnungtypus. This kind of theme usually contains three parts: 1) the theme clearly establishes the tonality (which occurs here through the elaboration of a D major triad); 2) the actual Fortspinnung (continuation) moves away from establishing the tonality, and frequently uses sequence; and 3) a conclusion, which contains a clear, strong cadence.
The first episode (concertino section) introduces the first new idea: descending, stepwise eighth notes, which might appear to slow down the motion, were it not for the continuous activity of the harpsichord. (The beginning of this passage can be seen in the musical example immediately above.) The slowing effect of the eighth notes is countered by an accelerating effect in the next phrases when Bach includes sixteenth-note triplets in the solo lines.
The brief return of the ripieno accompanies a brief shift to the relative minor key of B minor. The acceleration affect continues in the next episode with thirty-second note scale passages in the harpsichord; such small note values are something Bach normally reserves for slow tempos, not an allegro. In a subsequent, rather long, episode, the feeling relaxes, as Bach drops back to constant sixteenth notes (as at the opening), with solo flute and solo violin exchanging phrases (and measures) on a rocking idea:
Bach helps relax the feeling by slowing the harmonic rhythm at the same time as he pulls back to lulling effect of the constant sixteenths and repeated rhythms of the flute and violin. This middle section has the feeling of a development, especially when the opening material and key returns later in m. 121.
Bach pulls a major surprise a short time after the opening material returns - a cadenza of sorts, for solo harpsichord. There is considerable build-up to this moment, with the activity and intensity increasing in the harpsichord part leading up to this (from about m. 140 onward); the ripieno sections lessen their contributions, perhaps distracted by the activity in the harpsichord, until they finally drop out (m. 154) and the harpsichord continues alone. There is some debate as to whether this solo passage really constitutes a cadenza or not, but I believe most modern listeners will view it as such - the harpsichord plays alone, a virtuosic passage of some length leading ultimately to a big cadence, at which point the tutti returns (m. 219) to bring closure to the movement.
The second movement contains the marking "affetuoso", and is notable for the intimacy that results from Bach's scoring of only the solo instruments (flute, violin, and harpsichord).
The third movement combines the use of a ritornello with a fugue. The solo instruments introduce the fugue subject (includes two statements in the harpsichord, one in the bass, and one in the treble), and complete the exposition. The ripieno enters in m. 29 with additional statements of the subject, and from here on the subject recurs occasionally as a ritornello (and at other times as the jumping-off-point for the soloists in a new episode), while serving as a unifying theme throughout the movement.