They have. Legumes are an important way to fix nitrogen (while simultaneously growing food!).
Why haven't ALL plants evolved to fix nitrogen? It's abundant in the air... and also in the ground. You don't manufacture your own vitamin C, but you could. But there's no need. Humans specifically evolved the inability to do so, where almost all animals can and do.