The gap in achievement between the richest and poorest pupils in Scotland is widening, figures have shown.