Because several times various characters suggest that someone Apparated or Disapparated to/from the Hogwarts grounds.
To the best of my knowledge, it is commonly suggested when people appear or disappear quickly while in Hogwarts (like Barty Crouch did, according the the Map, in Book 4). Someone will suggests Apparition to explain the quick exit, and someone else (usually Hermione, but later occasionally Ron and/or Harry, once they've heard it a lot) will use the quote to shoot down that explanation.
It's also worth noting that it isn't strictly true. The current Headmaster can apply or remove that restriction (seemingly at will), and routinely does when the Sixth-Years are learning how to Apparate. The wards which prevent Apparition can be damaged or taken down by attackers (as occurred during the Battle of Hogwarts). Lastly, House-Elf teleportation - though superficially similar to apparition - is not affected. It's possible this is only true for Elves bound to the castle, but we cannot be certain of that as we never see a non-Bound elf try 'on screen'.
As for the out-of-character reasons, J.K. Rowling made Hogwarts a 'teleport-free' zone. Why she chose to do this is not known for sure, but it is possible it was to cover potential plot holes (like why upper-year students didn't teleport out when there was trouble, or why Aurors couldn't quickly respond to the latest problems).
Once this was decided, she had to put it into the books (so her characters could inform the readers). Presumably the question kept coming up, so she made sure her characters kept reinforcing it. Eventually, characterization picked it up and it became almost a catch-phrase for Hermione, which the other characters could use to tease her.