Easy $50 Start (New for 2018)
Buy the World Fun and Ocean's Bottom sets:
1) Get a Fantasy and Historical Minifigures collection:
You will get a good collection of people and accessories, and even a few bits of terrain, for about $55 after shipping (as of early 2018. This is a discontinued set, and the price keeps creeping up.) Let your players make their PCs by mixing and matching whatever parts they want from the people there, and then use the rest to make NPCs and humanoid enemies.
2) Get the latest Creator 3-in-1 creature-building set (currently Mythical Creatures). The sets rotate every year, but they usually have something good for less than $20. Make one of them, have the players disassemble it in-game, and then make the next one for the next session. Then use the parts to build your own monsters.
3) Get a Classic Creative Supplement and use it to make modular terrain pieces.
4) Get a couple little sets from whichever theme best fits your campaign style. Suggestions are on my latest set recommendations page.
If you want to spend more time or money, you have several options.
1) Used Lego
Lego bricks are incredibly durable; 30-year-old ones are almost as good as new. The worst case scenario is that they are dirty or dusty and you have to clean them up.
shopgoodwill.com is a great way to buy Lego. I use it often. The prices are better than ebay, and it is not dominated by expert sellers who pick out all the good stuff from bulk lots. Search for 'Lego pounds' to filter for bulk collections, and bid on something that looks good. Sometimes, the lots that say 'no minifigures' will actually have disassembled minifig pieces that you can assemble into people; look for disassembled legs or heads or torsos in the item picture.
Craigslist is also an option, depending on your area. You might get a very good deal on an ideal used collection, although the usual caveats for dealing with people apply.
Obviously you should aim for a collection that has a lot of Castle, Pirates, and/or Harry Potter sets. You might get lucky and find one with Elves, Vikings, Monster Hunters, Chima, Ninjago, or Lord of the Rings sets. But with a little creativity, you can use any kind of Lego set. Both the Lego space sets and the Star Wars sets have a lot of figures and accessories that work surprisingly well in a D&D game, and a police officer from a Town or City set can be turned into a medieval town guard by giving him a sword.
Serious Lego hobbyists (and people who got five dozen handless legless minifig torsos in a shopgoodwill bulk order) use bricklink.com to buy individual parts they need. If you want hundreds of bricks and plates to make a full dungeon map, with a Lego baseplate floor, get them here.
2) Creator Sets
If you are not able to find a good source of used bricks, or do not want to buy anything used, or have little Lego experience and are not comfortable building things without instructions, the Creator sets are a good value for terrain, settlements, and sometimes monsters. They usually come with instructions for three different things. Following these instructions, and the extra build ideas, will give you experience in working with Lego bricks to make lots of different things. Lego keeps making new sets and retiring old ones, so I will not give specific links here, but check my latest set recommendation page for specific guidelines.
3) Individual Sets
Individual sets will often give a good mix of interesting new minifigures and weapons, terrain, and/or large monsters. Aim for the ones that have structures, not vehicles, although some vehicles can be remade into large monsters. Again, see my latest set recommendations.
4) Basic bricks
If you are already confident in your ability to use Lego bricks to make lots of things, or you just need a lot of basic bricks to build dungeon wall segments, get the basic Lego brick buckets. They are the best value for the money for buying basic bricks new. Again, the exact items change every couple of years.
If you live next to a Lego store, you can go in and make three custom minifigs for $10. This can be a good way to fill specific holes in your collection.
6) Random Minifigures
It is my last choice, and probably the least cost-effective way of building up a collection of PCs and NPCs, but the random minifigures often have a lot of very nice things that you cannot get anywhere else. Each series of 12 random figures will typically have about 6 that are really nice for a fantasy setting, 3 or 4 that are marginal, and 2 or 3 that are worthless. At $4 each, with about a 1 in 5 chance of getting something useless, you are basically paying $5 per useful figure.
You might consider buying specific ones on the secondary market, but from what I have seen, the ones you are likely to want for a D&D game will cost more than $5, so you are better off playing the odds and getting the extra people to be creative with.