Depends on what your focus is. If you want to build understanding of electronic components and how they interact through experimentation, Paul Falstad's circuit simulator is a great start.
If you want to focus on digital logic, Logisim is great.
But here's the thing: A microcontroller is controlled only through code. You want to learn electronics, you can simulate those. You want to learn about a specific microcontroller, read the manual for that controller. You want to learn to code a particular language, you learn that language.
You want to code on a microcontroller, get a microcontroller.
Edit:
Okay, so i was clicking around on Falstad's site as i haven't been there for a while and i found a thing called AVR8JS
This is literally what you are looking for! It allows you to set up a circuit, and use a simulated microcontroller to run C code on the circuit!