In order to qualify for the maximum state pension, individuals need to have paid sufficient National Insurance Contributions (NIC) for the requisite number of tax years.
The number of tax years required depends on when the individual reaches state pension age. Those that reach state pension age on or after 5 April 2016 need to have paid NIC for 35 full years.
HMRC have a useful online state pension checker facility which is available at https://www.tax.service.gov.uk/check-your-state-pension
It is possible to pay voluntary NICs for missing years but you can usually only pay for gaps in your National Insurance record from the past 6 years.
Further information is available at https://www.gov.uk/voluntary-national-insurance-contributions/who-can-pay-voluntary-contributions