Based on what I remember, there were a few factors that eroded Internet Explorer's dominance starting around 2005:
1. Greater awareness of the security problems Windows had during the mid-2000s, especially surrounding Internet Explorer and ActiveX. This encouraged web users to use alternative web browsers, and this encouraged web developers to drop ActiveX for other technologies.
2. The release of Mozilla Firefox in 2004. The browser had an excellent reputation for its speed and its support for the latest web standards (something I'll get to later), and it had tabbed browsing, which Internet Explorer lacked at the time.
3. The Web kept evolving while Internet Explorer's development essentially halted after IE 6 was released. There were new standards that web developers wanted to take advantage of. Firefox took advantage of them, but because IE's development essentially halted, IE 6 didn't take advantage of them. By the time Microsoft finally started work on IE 7 (it was released in 2006), Firefox already received significant mindshare, especially among tech-savvy users.
The latter half of the 2000s and the early years of the 2010s were a golden age for the Web. There was competition in the browser market: Firefox kept advancing, Opera was still popular, IE became competitive again, Safari was a nice browser for the Mac (and even had a Windows port at some point, though I don't know if it was ever popular), and Google released a nice, fast browser named Chrome that started gaining momentum. Web developers generally respected web standards and didn't engage in "Best viewed in X browser" shenanigans like during the Bad Old Days. It was a wonderful time.
Of course, over the 2010s, Chrome became the dominant web browser, Firefox lost momentum, Internet Explorer was replaced by a Chromium fork called Edge, and unfortunately we're starting to see "Best viewed in Chrome" websites and Google having outsized influence over Web standards. There's a new 800 pound gorilla in the jungle.