Original D&DWhen the very first version of the game was released in 1974, there were no Lego minifigs. The first proto-minifigs were released in 1975, the year that Greyhawk was released and the game became independent of Chainmail rules:
That is basically the entire catalog of minifigs, and of sets other than basic bricks that might be useful in a D&D game, in 1975. There was nothing medieval, and no fantasy elements, but you could have made it work. All you need for castles and dungeon walls is basic bricks, and cowboy hats are always a good way to represent adventurers. All of the monsters would have been brick-built, with no advanced building techniques, because they did not have any pieces other than wheels and fences to make studs go sideways. Here is a humanoid enemy build that one of the people used:
Depending on the desired tone of the game, you could leave those faces or replace them with something brick-built. You could also use them to make four-limbed things.
Advanced D&DIn 1978, the year that the AD&D PHB was released, Lego started selling its first actual minifigs, and a Castle set with medieval weapons and armor:
There were a few other options for equipping minifigs for dungeon-delving. Here are some guys with pick, shovel, handaxe, and a different helmet style:
And that is basically it. Any game would have to use those minis and tools, plus brick-built things. But people were already running games with Lego. Creative children will use whatever they can get their hands on.
2nd EditionWhen AD&D 2nd edition was released in 1989, Lego Classic Castle had been going for several years. There were more realistic castle/dungeon walls, a better variety of equipment, elements like barrels and treasure chests, and even minifigs suitable for elves:
Also in 1989, Lego introduced Pirates, giving more elements and clothing options, and minifigs with faces:
3rd EditionBy the time 3rd Edition was released on 2000, Lego had been producing fantasy-themed Castle sets for years:
There were skeletons, ghosts, dragons, witch and wizard minifigs, and a huge variety of specialized weapons and armor. There were also oriental-themed sets:
and the Adventurers sets:
At this point, Lego sets are practically begging to be used in a D&D game.
Everything produced since then is just icing on the cake. All of the new minifigs and accessories are nice, but not essential. The only things that I would really miss if I was limited to 20th century Lego are the click hinges, technic friction pegs, and mixel ball joints that let you make much better customized brick-built monsters.