This is a common issue. Windows 10 is good at finding generic drivers, but it often misses the specific optimization drivers needed for the OptiPlex 5040 to run at its best.
Before we dive into the download links, it is important to understand why the "default" Windows drivers aren't enough: dell optiplex 5040 drivers for windows 10 64 bit