It’s because climbing them can kill you. Actually, climbing UP isn’t the problem, climbing DOWN is. A sweet friend of mine died falling down The Great Pyramid of Giza (also Khufu or Cheops) in 1980 during a college study-abroad program — it was a tragedy. I’d climbed it earlier that day with some other friends. With no serious fear of heights, it’s not too difficult for someone in reasonable shape to clamber up in 10–15 minutes.
On the descent, however, you basically have to jump down, rock by rock. Jump, jump, jump, hundreds of times. Remember, the pyramids were originally covered in polished limestone, they weren’t designed as stairs. What’s left are the ragged remains after pillagers later stripped off the limestone coating to construct local buildings. The stones are uneven, ranging from a few feet to 6+ feet tall (see the photos).
Many of the landing spots are smooth, slippery, and covered in 4,000 years of sand or loose rocks. They can be angled downward, narrow, or cracked. There are few trustworthy handholds. With the ignorant fearlessness of youth, the ascent felt exciting, not life-threatening. Climbing up, it never occurred to me that any minor misstep would be fatal.
Think of it as climbing the outside of a 45-story building without any safety equipment. You truly can’t understand exactly HOW perilous it is until you’re high up and already in serious jeopardy. Imagine jumping around the ledges outside your 35th-floor office window. I’d intended to climb to the top but when I stopped for the very first time perhaps 3/4 of the way up, turned around, and looked down, I promptly changed my mind. The unobstructed view 350 feet straight down was dizzying.
My friend was athletic but she must have slipped during her descent. In retrospect, this could have happened to anyone. It’s steeper than it appears, so once you lose your footing, you won’t stop tumbling until you’re at the bottom.
We later learned that her fall was not an isolated incident. Below are a few of my photos, for context. [Update: I just learned from some of my fellow 1980 students that climbing was illegal even then, but they’d slipped the security guards a little “baksheesh” to look the other way. Interesting, I’d just walked over and started climbing, no one bothered me.]
The view from the climb, approaching the top:

The view up, from the base:


Photos (c) 2018 Ross Fishman
I’m assuming you mean any pyramid.
There are hundreds of pyramids scattered through Mexico and Central America, many of which allow you to climb.
This was at Yaxha National park just inside Guatemala. It is not too far from the much more famous Tikal, but had almost no other visitors. There were many pyramids, some that were still yet to be uncovered. The park allowed visitors to climb many of them. They even offered properly built stairways that were hidden out of site, usually behind the pyramid that allows modern visitors to safely reach the top. They know what the visitors want. And that is to climb the pyramids!

The famous chichen Itza does not allow climbers (at least when I was there). I don’t blame them. Can you imagine what this thing would look like with vendors crawling all over it hawking all that tourist crap. Actually this place was pretty disappointing. The venders were totally out of control. But at least they kept them out of the photo areas.

The famous Tikal did not allow climbers either, well unless you paid them to take a special sunrise tour. I’m kinda regretting not paying for that.

Xunantunich Mayan Ruins, San Jose Succotz, Belize was one of my favorite stops. They let visitors climb over just about everything, and there was plenty to explore. This was my mascot before the wind sadly blew here off a ledge, not from a pyramid, but a bridge in Guatemala City. I still cry for her.

This is the top of the same pyramid in the photo with my mascot. Notice the total lack of shade. The sun is very strong down there. I went through a lot of sunblock.

Uxmal near Merida, not to far away from Chichen Itza was another beautiful place. They didn’t allow climbing, but during my visit, almost nobody was there and they didn’t stop anyone. I liked this place so much more than Cbichen Itsa. There were almost no venders and it felt like I had the whole place to myself. Go on a weekday instead of a weekend if you can, is so much better.

This photo of visitors scaling one of the pyramids at Orange Walk in Belize, shows just how steep some of these thing are. Seriously, one careless mis-step off of one of these and you are dead.
Climbing these deserves every bit of care and respect that you would give to climbing a two-hundred foot vertical cliff. Just because the ancients etched in some stairs does not make them safe.
With that said, the feeling of standing at the top of one of these is nothing short of incredible.
Finally, if you would like to visit Belize or Mexico or Central America, I recommend that you to take some time, and really plan your trip. Travel is an art that cannot be fully appreciated when someone is leading you aroundon a leash.
The trip I took when I visited these was actually a solo, self guided bicycle tour which I spent two years planning in advance. That is, starting two years before I retired from the Navy, Every day after work, I got on my PC for a couple hours and charted out 50 miles of travel. That part was just as rewarding as actually going on the trip.
The bicycle portion of that trip lasted 7 months and covered 5,020 miles.
After all my careful planning, followed by thousands of miles of pedaling , and I reached Orange Walk, or any Mayan site, or Aztec site, and climb those stairs, I knew I earned the top of that pyrmaid, and it was a wonderful feeling.