An asteroid large enough to do the sort of damage depicted in the movie (which Rose's father described as "peeling the Earth, and the peeler is fire") would have to be bigger than the Chicxulub Impactor, which makes it unlikely to have gone undetected for so long.
It would, realistically, have to be something with a short warning time. The fact that some people seemed to suicide before it struck (as mentioned by the protagonist's mother) suggests that it was known to be coming for awhile, ruling out more bizarre options like a supernatural plague or a "rod from God" launched by an alien civilization. Neither would necessarily have to be sudden, but no one seems angry at anyone for launching it, so they don't seem to be aware if it was. The most likely option, then, would be a comet with a long orbital period that had remained in the depths of space for most of human history and only recently developed an Earth-intercepting orbit.
It seems unlikely that nothing would be attempted to stop an Earth-destroying impact, given any sort of warning beyond a few weeks. Since anything capable of the damage depicted in the film would have to be found further out than that even if there wasn't much more warning, it stands to reason that someone would try to do something about it.
The dialogue at the very beginning of the film sounds like two military units talking to one another. It also sounds like one of them is in a situation that is completely FUBAR. Everyone around them has died, but they're still alive and able to transmit for a moment. Then, they cut out into silence as well, and the radio chatter is replaced with horrified and/or consoling phone calls.
It sounds like the movie was trying to imply an attempt to stop the Impactor by pulling off a stunt like in Armageddon with astronauts landing on and deflecting it somehow. Unfortunately, it was apparently failed when one crew died as a result of an accident, leaving the other alone and unable to finish the job.