Foreign keys are allowed to have NULL values because they are used to refer to a table from another table and it can be the case that some rows in the table might not have any relation to the other table in that case that row's foreign key field would be NULL meaning this row is not relating to the other table.
Consider an employee and department tables,
Employee(Name, Id, DepartmentId)
Department(DepartmentId, DepartmentName)
Here, DepartmentId of Employee table is foreign key to Department table's DepartmentId, now consider a new employee joins the organization, we don't know what department he will be joining so we can have DepartmentId for that employee as NULL but for other employees it can be there. This NULL value shows that employee till now is not related to any department.