Maximal inequalities and applications to regularity problems in the calculus of variations