Probably not the answer you were hoping for, but I think the best way to get upgraded is to fly a lot with the airline. Generally when the flight's overbooked in one class, and they're trying to pick which person to upgrade, frequent flyer status is the first metric they use. The higher your status, the higher up the list you go!
Having a high status with a partner airline can work too, high tiers with a partner airline usually comes below the airline's own frequent flyers, but above everyone else.
Otherwise, if you're flying on your own that'll help in the event that there aren't enough frequent flyer to upgrade to free the required number of seats! Being polite and smartly dressed can help.
Offering to pay may be an option too - if they're pretty full they may offer you a low price to upgrade, on the grounds that some money from you is better than none from a free upgrade to frequent traveller. Ask at checkin about that, and see what they say.
If you have a title, make sure that's on your booking. Friends of mine who are doctors seem to get upgraded more than ones who aren't, and the airline needn't know that you happen to be a Doctor of 14th century poetry or astrophysics, rather than a medical one!
In general though,the busier the flight, the more likely an upgrade. There are a few airlines that'll upgrade people to fill a higher cabin, but most these days will only do it when a cabin is full.
A different option is to volunteer to be bumped off a very full flight, but upgraded on the next one they put you onto. I know Delta to that for an example, but I think it's a fairly general possibility. Does require a very busy original flight though, and the airline really wanting people to opt not to fly!