What happens when you knead bread dough?
Kneading dough has a few functions. First, it distributes the ingredients together evenly and allows the flour to become hydrated. As the flour starts to absorb water, enzymatic reactions occur and some proteins begin to mesh together. The two most important in this process are glutenin and gliadin. When these proteins start to get tangled up together, they form gluten, which is the protein that allows bread dough to stretch and trap gas bubbles produced by yeast. These reactions will occur on their own to an extent, as in no-knead recipes, but kneading accelerates the process.

Kneading also allows you to control the texture of the bread. A vigorous knead can help to produce a bread with a fine crumb as the kneading an tighten the gluten, keeping the air bubbles more uniform. Doing short kneading periods (or folds) spaced by time for the dough to relax and rise can give you more extensible dough which can help give you a more open crumb structure. 

Finally, kneading is sometimes used to add inclusions to the dough that would disrupt it's activity if added to early. This can be things like seeds, which would cut gluten strands if included too early in the process, or things like butter in a brioche, which would shorten the dough if included before the gluten had already developed.