Educational attainment is improving overall in Scotland, but there is a need to close the gap between the lowest and highest performing pupils.