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.
You must checkin no later than 45minutes before your flight. It’s a TSA requirement so they can confirm the manifest
I’m guessing that’s a USA-only rule.
The TSA doesn’t have much authority over other countries
It’s all there in the name: the Transportation States of America
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.
Why would the TSA care about when I check in?
It’s a good idea to avoid being bumped out of a flight because they ended up overbooked
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 don’t think it’s ever been required but it affects where your seat assignment is I believe.