"What is a weed? A plant whose virtues have not yet been discovered." - Ralph Waldo Emerson.
A good example is garlic mustard. Highly invasive, but the greens and taproot are edible when cooked properly. I digress, so back to the question at hand...
Weeds are advantageous. Many people excessively water new lawns/gardens in attempt to establish them, but this merely promotes weeds. An established lawn/garden is the best way to prevent weeds. Water only when absolutely necessary.
Disturbed soil is perfect for weeds as well, hence weeds springing up in the garden. Many weed seeds lie dormant for years until they are tilled to the surface. I have had a tough time in my garden this year with velvet leaf. It is not a tough plant to control, but it is a bit annoying when so many pop up after tilling.
Take notice of a lawn when there is a drought. Broadleaf plantains and prostrate spurge (at least in my area) seem to flourish when grass goes dormant in mid-summer. Thistles also take over when all the native and desired plants struggle. Their deep taproot can still draw moisture during drought, while the rhizomes (underground stems) spread and send up more thistles. Many weeds, like thistles, can be hacked down to ground level but still recover and produce even more vegetation than before.
Weeds are a perfect example of natural selection and how resilience pays off.