I believe ICAO (that would be the regulating authority) says be at the gate minimum 20 before departure.
Considering security queues, though, my advice is to check in online the night before and be at the airport at least 2 hours before departure for a large airport. Small ones you might be able to get away with less, but unless you go through regular and know the setup, I would not chance it. Your airline will give you instructions.
Check in counters normally close for bag drop 1h to 45min before departure here in Europe in my experience. Vast majority of airports also now support digital boarding passes in Europe.
My home airport is small so I can work with 1 hr before departure; Brussels was 20min queue at security; Frankfurt we were there 2h30 before departure but at the gate for less.than 10 minutes, queues were that long and slow-moving.
TSA knows who you are way ahead of time when you put your secure flight information in, and maybe it checks the information when your boarding pass is printed. Airlines close check-in so they don't have unexpected people showing up during boarding. But if you get rebooked on a different flight or something, they can check you in at the gate whenever.
Also, United and Delta let you check in 30 minutes prior to departure if you don't have bags.
This is heavily dependent on your region, country, and airline. Some commenters immediately answer like you were in the US but those might not be valid for you.
Bingo bango, just do it when they ping you. You don't have to, but I don't want to give any airlines any hope that there might be a seat available. Overbooking is stupid but they bank on people missing their flights, I don't want them to think my seat is one of the ones available
It's use is limited for some situations. Especially when you don't only have carry-on, some places still require you to stand in line for checkin. Then you barely have a benefit doing an online checkin.
However, more modern airports/airlines have automated the checkin process, even offer tags to print at home and automated bag drop areas.
For these situations it's pretty good to check in online and just walk past the lines.
I dunno how required it is, but I still make sure to do it.
Also I love it when I check in on my computer and it tells me I've successfully checked in, but then at the airport when I try to pull up my boarding pass on the app it acts like I haven't checked in and makes me do it again.
When I fly Southwest, you're supposed to check in starting 24 hours before to get a decent position in line. You can pay extra to get a guaranteed spot in boarding group A, but as long as you check in on the dot you'll get at least B. Wait till the last minute and you'll be stuck in a middle seat in the rear on most flights. Not sure how it works with other airlines, though.