Why contrast matters
Text that's too close in brightness to its background is hard to read in sunlight, on cheap screens and for people with low vision. The WCAG guidelines set minimum contrast ratios that many organizations use as their accessibility standard.
Fixing a failing pair
Darken the text or lighten the background (or the other way round in dark mode) until the ratio passes. Changing the hue alone rarely helps — contrast is about lightness.