C@C, the legislation is Section 89 of the Digital Economy Act 2017,
"9TV licence fee concessions by reference to age
(1)The Communications Act 2003 is amended as follows.
(2)Section 365 (TV licence fees) is amended as follows.
(3)After subsection (1) insert—
“(1A)Liability to pay a sum under regulations under subsection (1) is subject to any concession applying in accordance with a determination by the BBC under section 365A.”
....
(1)For the purposes of section 365(1A) the BBC may determine that a concession in specified terms is to apply.
(2)Any concession under this section must include a requirement that the person to whom the TV licence is issued, or another person, is of or above a specified age, which must be 65 or higher, at or before the end of the month in which the licence is issued."
That gives the BBC the right to decide the conditions under which a free licence is given to those of a specified age.