NSW public schools are set to benefit from $4.8bn in funding after the state and federal governments reached a new agreement.