Why does a (vodka) martini often come with an olive on a stick?
Olives (and onions) are a very traditional garnish used by bartenders to add a slightly savory flavor to a drink. As with many things behind the bar, they're used nowadays largely because they're iconic, but they do have a subtle effect on flavor.

It's not really known where traditional garnishes such as citrus peels, cherries, olives/onions, and mint sprigs originated, but they're found in the earliest known published bartender's manual. (This was Jerry Thomas' How to Mix Drinks or the Bon-Vivant's Companion; cocktail historian David Wondrich's book Imbibe!, which reorganizes and provides context for the original, is required reading for the modern cocktail nerd.) These garnishes may have started with early drink families called cobblers and juleps which feature fresh berries and mint, respectively. Over time, drinks got more elaborate and drinkers came to expect something added to their drinks to give them more visual appeal. Here's a great, brief article that breaks down some of the history and usage of these.

At first, as seen in other early bartending guides, bartenders just tossed whatever they had (usually preserved or pickled items that kept well including nuts, olives, and cherries) into the drink on hand. Eventually they sorted themselves out and figured out that olives or onions went best with savory drinks such as the Martini, and cherries went best with sweeter drinks such as the Manhattan.  The tradition solidified a few years before Prohibition in the US, and was one of the practices that survived the resulting upheaval in drinking traditions.

In the 1950s, Martini practices grew more variable; when ordering, you'd be quizzed about whether you wanted vodka or gin, shaken or stirred, an olive or a twist, without any particular standard. The olive may have become even more tightly associated with the Martini later on, when drinks began skewing to sweet and fruity in the late 1960s and 1970s, and fresh citrus started disappearing behind the bar. For whatever reason, bartenders also seem to have forgotten how to store vermouth (which, since it's a wine, will go off if stored at room temperature and allowed to oxidize) and the olives may have been the only thing preventing Martinis from being unpleasantly bitter. By the 1980s, the "dirty" Martini (which adds a dash or more of olive brine) emerged as one of the few options for drinkers who wanted a non-sweet cocktail at a bar. Fortunately, we've now come full circle, and a Martini closer to the original pre-Prohibition version can be found at many cocktail bars (usually with a twist of lemon peel).  But the olive has now been firmly established as the traditional Martini garnish for multiple generations.

One of the main reasons that the briny olive works as a garnish is because a small amount of salt is a flavor enhancer, which is why just about every savory dish that we eat (and some sweet ones, ala salted caramel) contain at least some salt. There aren't many drinks where salt is added directly, but there are certain drinks (such as the Margarita) where it's an important part of the flavor, and some modern bartenders with a culinary background use a couple drops of salt solution in almost all of their drinks. Some people particularly like this in a Martini, especially if that's what they're used to.

So, the tl;dr: It's now seen as traditional, some people really like the salty flavor it adds, and it works pretty well in a largely savory drink like the Martini.