The difference is that a DSLR literally has a mirror behind the lens angled up to the viewfinder. When you hit the shutter, the “click” you hear is that mirror moving out of the way so that light can now hit the sensor. That’s why the viewfinder goes dark when you hit the shutter: because the mirror was the only thing letting you see through the lens. You can see that mirror when you take the lens off the body of a DSLR.
Mirrorless cameras use electronics to both look through the lense and to capture the light from that lense. You can see it when you take your lens off the body of a mirrorless camera. This is also why mirrorless cameras don’t have a click unless the manufacturer put one in there artificially since people are used to it. It’s also why they are so fast; since there is no physical mirror to move inside the body.
In a DSLR, there is a mirror in between the lens and the mirror. The mirror is angled so it brings the light coming from the lens to the viewfinder. When you take a picture, the mirror flips out of the way, so the light can get to the sensor. This also means that the camera body needs to be a bit bigger and heavier to accommodate the mirror and related components. A mirrorless camera doesn’t have a mirror and the viewfinder is essentially a tiny monitor that shows the processed image coming from the sensor.
The main advantage of DSLR cameras over mirrorless cameras used to be that what you saw in the viewfinder was (and still is) exactly what your lens saw, and therefore what was going to be on the picture. Not necessarily exactly what your photo would be, as effects of lighting and depth of field were not visible (these are amongst others affected by the shutter opening you chose, some cameras have a button to apply that to the viewfinder). Mirrorless cameras used to show an imperfect view of that, and usually with some delay, and pixelated. Those cameras have much improved over the past years, to the point that the quality of the viewfinders are comparable.
When buying a camera today, it’s really more about your preference than about which one is better.
Adding to the other responses, getting rid of the mirror allows you to move the lens much closer to the sensor. It’s really hard to make wide angle lenses with a focal length shorter than the size of the mirror. So wide angle lenses designed just for mirrorless cameras can be smaller, cheaper, and higher quality.
Latest Answers