The only binding requirements are that you:
- check-in before the check-in deadline (which depends on how you check-in, the airport, the airline, sometimes the class or other parameters)
- drop your bags before the baggage drop deadline (ditto)
- be present at the gate before the boarding deadline
It's up to you to make sure you meet those deadlines. If you're not at the gate in time because it took hours to go through security, they have no obligation to accommodate you, whether you arrived 5 minutes or 5 hours early at the airport. Note that they would generally have no way at all of knowing when you arrived at the airport anyway.
Many (most?) airlines will actually have gestures of goodwill if the situation is unusual and there were longer delays than one may reasonably expect, or other similar reasons (e.g. if there was an abandoned bag which caused a significant part of the airport to be closed, etc.), but they're generally in no obligation to do so.
In the US, some airlines have an official or unofficial "flat tyre" rule which gives you some leeway if you get to the gate a bit too late but not too much, but that's more the exception that the rule IMHO.
How long in advance you should be at the airport varies a lot based on a number of parameters:
- Whether you have checked luggage or not
- Whether you have already fully and successfully completed check-in online or not (i.e. you have a valid boarding pass)
- Whether you need to take any other additional steps at the airport (e.g. non EU/EEA passengers on Ryanair flights who need to undergo "document check"), or of course duty-free form stamping, or if you have checked luggage, any overweight/extra luggage charges to pay
- The airport
- The gate your flight departs from. There are gates in some airports which take less than 5 minutes to get to. There are other gates which take well more than a half-hour to get there (in larger airports with multiple concourses, where you have to take a train or bus, etc.)
- The day you're travelling on. Don't expect to breeze through security on a busy day like the first day of school holidays or before important holidays (Christmas in Europe, Thanksgiving in the US, etc.), or even on long week-ends.
- The class of travel and if that gives you access to fast track or not.
- The current situation. Follow the news and check the airport's and airline's websites for up-to-date info about any disruptions.
- Your mode of transport to the airport and any delays you may incur/backup plans.
- Whether you need to go through exit passport control (usually a lot faster than on entry, but there can still be nice queues).
- How well you know the airport
- How "well travelled" you are. Some people travel so much that you can drop them in any airport and they'll find their way in a second. Others, well, let's say it can take them a while.
- How fast you walk/whether you have lots of "encumbrances" (aka kids, strollers, etc.).
These days many airports have significant disruption as soon as traffic picks up a little. Common advice from many such airports is to arrive 3 hours before your flight.
For a passenger used to travelling, in a small, well organised airport, with no check-in luggage, check-in done online, not on a busy day and with fast track, arriving one hour before departure is usually more than enough (I have arrived much later than that on many occasions).
If you don't have fast track then it becomes very dependent on how busy security is, and that can range from minutes to hours.
If the airport is large and/or with multiple concourses, that can add a significant amount of time to get to the gate.
On any busy day, arriving 3 hours early is probably a good idea.