This is somewhat dependent on location, but, generally, is a relic of a bygone era. It's usually just not going to happen anywhere these days, especially to business or first.
In North America, complimentary upgrades to business or first class are very common... but they are given to frequent flyers based on a very specific set priority, not just to random people who ask. On long-haul international flights, they're given either to people who pay with miles, people who use upgrade certificates (these are issued to frequent flyers only,) or airline employees who are flying as passengers on the flight. And, of course, they (usually quite successfully) try to sell upgrades to open seats up front. Obviously, the airline's very frequent flyers are not going to be happy if their upgrade is instead given to some random person who just asked to be upgraded, so that's pretty much never done these days.
Outside of North America, complimentary upgrades are significantly less common, even for frequent flyers, and airlines will happily let seats go out empty in business or first if no one is willing to pay for them. I've had flights in East Asia where I was the only passenger in business or one of only a few, despite there being tons of people in the back.
There are really only two situations nowadays where you might be upgraded to business or first for free without using miles, having frequent flyer status, or working for the airline:
When economy is overbooked, they'll sometimes move passengers up to empty seats in business/first. This generally won't be something you can ask for, though, but rather done by the airline based on fare class purchased, time of ticket purchase, etc. And this will still usually go by the normal upgrade priority, so these will probably go to frequent flyers anyway unless there just aren't any.
When you have to be rebooked on another flight (for example, due to flight cancellation or delay or due to volunteering to take another flight in an overbook situation,) if the only seat available on the next flight is in business or first, they'll usually just put you there. My first couple of flights in First were for that reason.