The short answer is wind happens because the Sun heats some parts of the planet more than others, and this uneven heating starts a wind going. That means wind energy is really a kind of solar energy!
All winds are made the same way
Wind systems on Earth vary from the global-scale trade winds and jet streams to local sea breezes, but they all ultimately depend on Earth being unevenly heated by the Sun.
When the ground is heated during the day and gets very hot, it heats the air above it by a process called heat conduction. This makes the air expand to occupy a larger volume. According to something called the “ideal gas law”, the volume increases in direct proportion to the temperature.
In other words, the heated air is less dense. If this happens to all air, no wind will be created; the whole air layer will just be a bit thicker.
However, if it happens to air in one location but not its surroundings, the heated air will rise. This is the principle that allows hot air balloons to remain buoyant in the air: the total weight of the air in the balloon, plus the basket and people inside, must be about the same as the weight of the same volume of colder air outside the balloon.
If there is no load or tether, the balloon will just keep accelerating upward until it cools off.
A rising hot air balloon doesn’t create any wind because it’s too small. But imagine if the same thing happens to all the air over a whole city or larger region!
When such a large amount of heated air rises away from the surface, other air near the ground has to flow in sideways to take its place. The larger the area over which this happens, the stronger the horizontal wind needs to be to get all that air into position.
This phenomenon gives us daytime sea breezes near coasts that can be fairly strong, where cooler ocean air flows in to replace the warmed continental air as it rises up.
Over many days, a similar process gives us monsoons, because the heating is stronger in summer and weaker in winter, leading to strong temperature contrasts and winds in summer (and often, opposite ones in winter).
In turn, this leads to seasonal shifts in the prevailing wind, which often bring rains during the warm season in tropical areas including India and the top end of Australia.
There are some very big wind systems
These large wind systems happen because the tropics get more Sun than the poles and (obviously) become a lot warmer. That warm air naturally starts to rise and wants to flow toward the poles, while polar air wants to come down to the tropics.
Of course, it takes a long time (many days) for the air to make such a long trip. Meanwhile Earth is constantly rotating, which means things trying to move in a straight line will seem to gradually turn.
The poleward-flowing wind gradually turns toward the east and becomes the middle-latitude westerlies (westerly means “from the west”).
The low-level wind heading toward the tropics turns toward the west and becomes the easterlies, also known as trade winds because ship captains have used these to cross the oceans for centuries. The middle-latitude westerlies are very strong at high altitude, approaching 300km per hour in some places!
You can see a great interactive visualisation of all the winds on the planet here.