The main reason is that the batteries and other mechanical components in laptops are too dense for X-rays to penetrate effectively. This means that if you leave your laptop in your bag, security officials won’t be able to see what’s inside. They’ll have to flag your bag for a physical search, which slows down the screening process for everyone.
So next time you’re at the airport, don’t be annoyed when you’re asked to take your laptop out of your bag. It’s not just because the TSA is being difficult. It’s for your own safety and the safety of everyone else on the plane.