Pickle Accompanying Hotdogs, Burgers, Sandwiches in the US
Yes, you eat the pickle, if you like pickles - plenty of people do. You certainly won't get a pickle everywhere, but it's pretty common in deli/sandwich/burger type places.

I could be wrong, but I doubt there's any specific origin, and if there is, I expect it's pretty unremarkable - just someone who happened to do it first. Lots of cultures make one kind of pickle or another (or a dozen), and eat them as condiments/accompaniments. It's not surprising; it's one of the easiest and oldest ways to preserve food. Pickled cucumbers have existed for a long time in Europe too, so it's not surprising they're common in the US. The dill pickle spear is just by far one of the most common ones in the US, along with slices (often sweeter, called bread and butter pickles). The fact that they're the same everywhere is presumably just a product the industrialization of food production, like everything else we eat across the country.