1. In economics
teaching, a widget is just an unspecified thing that a factory
or a company makes. So you get exercises that say "Bloggs Widgets Inc. makes 200 widgets a year at a nett
cost of 5c apiece, with a profit
... How much...?", or they make six widgets a year at £1000 pounds each, and if each... .
It is just a variable used by economists, a bit like foo and bar in computers. I don't know where the word comes from but I'm pretty certain the usage in economics way precedes its borrowing into other fields.
2. Some twit had the bright idea of calling a thingummyjig used in cans of beer a "widget". This rather spoils sense 1. But what happened in recent years in England was that some bright spark, trying to sell real ale in cans, which is intrinsically a contradiction in terms, devised a kind of foofer that squirts carbon dioxide into the beer when you open it to give it a head. They needed a name: so they could call it a foofer or a squirter-upperer, or... well someone who'd done a spot of elementary economics obviously decided it was cute to call it a "widget".