Developers have been given the go-ahead to knock down a North Yorkshire village primary school and build a new one in its place.