Why was the production of the Lockheed SR-71 Blackbird halted?
Why did they stop building it?

Because they built 32, and that was as many as was needed at the time. 32 spy planes was plenty for the USAF/CIA to use, so building more would have been a waste. By the time those airframes may have needed to be replaced after 30 years or so, the SR-71 had been withdrawn from service and there was no need to build any more.

I think the question you're really trying to ask, though, is:

Why was it withdrawn from service?

And why wasn't it replaced when it was withdrawn?

The answer to those questions is a bit more complex, but essentially comes down to "Because it wasn't really needed any more."

The SR-71 was designed and built in the 50's and 60's. That means it was designed shortly before the first space flight, and built shortly afterward.

When designed, there was a huge need for a fast, "impossible to shoot down" reconnaissance aircraft. The SR-71 suited that - it could dodge missiles just by outrunning them, and by the time any adversary scrambled a fighter and got to the SR-71's altitude, the SR-71 would be a couple of hundred miles away and possibly even over a different country.

So what happened?

Satellites happened.

Why maintain a fleet of very high maintenance planes and keep them on high alert, then fly them over your rival's airspace? That's expensive, time consuming, difficult, risky, and (quite understandably) tends to upset your rival. It was, in short, an expensive way to annoy Russia and China. Okay sure, it got some reconnaissance too, and did its job (as an aircraft) beautifully, but when times are tense the last thing you need is to antagonise each other.

As an aircraft, then, it was a huge success... but as a geopolitical pawn, and as a military asset? It's a little more questionable. It certainly performed a vital role, but it had negative downsides from doing that.

Fast forward a few years, and we developed reconnaissance satellites with a whole bunch of advantages


With a few of them in the right orbit, you can have a satellite over an interesting part of the world pretty much 24/7. Even without that many, you can pass over an area pretty regularly.
Less obvious. Okay, your rival does not like you launching them - but once in space they're just "there", there's no antagonising "Oh look, an SR-71 flying over us"
They're "fire and forget" for the most part. Once in space, you just use it: you don't need to keep a bunch of pilots and aircraft on the ground ready to fly
It's less obvious what you're looking at, and when... if an SR-71 flies over the base that contains your new secret weapon, you're gonna notice. But when a satellite flies over for the 18th time today? Not so much
No planning and preparation time (which, for an SR-71, was a huge undertaking).  You just start taking pictures, or wait for a satellite to get to the right place, then start taking pictures.


They have disadvantages, too


For 24/7 coverage, you need quite a lot of them, and they aren't cheap
You have to replace them occasionally (and/or boost them into higher orbits)
If you upgrade your camera, it's a lot harder to replace the one on a satellite than an SR-71


But overall, a satellite is a more reliable, less antagonistic way to spy on your rivals. They're not perfect, but you know you've got permanent spying capability with no need to plan your reconnaissance ahead of time.

In short: It wasn't needed anymore.