Any merchant trader will tell you pirates are lazy @#$%! The exact translation of @#$% will vary by world but you get the idea.
The media presentations of pirates as charging in with lasers blasting are ... exaggerations to say the least. Lasers don't blast any more than a searchlight in vacuum for one thing. For another most merchants will stop resisting after a few well placed and low power shots tag them, or a missile or two is launched. A professional pirate simply demonstrates the means and will to end you and then the ball is in your court.
The problem all pirates must face is ... economics!
A pirate ship is a warship, whether converted or out of the dock. Warships have a number of features merchant ships do not, large magazines, oversized thrusters, barracks for troops, a large reserve of propellant and fuel... Merchants don't have these things because they eat up room that goes for cargo. Cargo, speculation and freighting is the merchant's life blood.
The merchants have an important edge on the pirates: fuel (or propellant if your setting uses rockets). Ships guzzle the shizzle. Your fat merchant could use up a lot of this running away and then hopefully top their tanks at the nearest port. A pirate finds a rather warm reception if he tries that. Now there are installations that will refuel and service pirate vessels. Usually they are not frequented by merchants so you need fuel and time to reach them. If a merchant gets in a lucky shot with a laser and the pirate ship loses fuel they may be stuck pending a quick patch job and some tense negotiations.
Other pirates also laugh at you a great deal upon hearing this.
So pirates like merchants try desperately to maximize their profits and minimize their risks. Yes there are head cases, terrorists and sociopaths out to maim, murder, and loot. They don't last long. In fact many are exterminated by pirates who realize the nutcase are going to bring the Navy down on their necks.
So smart pirates try to hit ships with known and valuable cargos. Insured or freighted cargos are preferred because no one is going to push their luck defending another person's booty or booty they get compensated for.
They also run the extortion game. A lot. That cuts down on risks but nothing helps the dependency on
Borsten's Leap was situated in a less developed area between two civilized pockets. Trade began between the pockets and a guy named Borsten decided to set up a colony and a starport in position to cut a few weeks off travel times and refuel merchants. The star system had gas giants but they were very far out past a couple of asteroid belts. Borsten's High Port grew wealthy on ships passing through and began gouging on fuel prices and various services knowing the merchants wanted to move on to trade elsewhere and wouldn't schlep out to the gas giants to refuel. they did want all manner of legal and illegal services the Borstenites provided. Borsten's economy grew around a system of services provided and the local currency was backed by coupons for back massages and the like, not gold or other precious metals. It worked.
A sizable community of belters had spread in the belts. Borsten's Leap welcomed them, and gouged them as well. In particular the Borstenites established a search and rescue operation and demanded the belters pay their share. The Belters insisted they did not need such a service as they looked after their own or let them be examples of Darwinian evolution. But the Borstenites followed up with a huge SAR tax for many services and goods. Never piss off a Belter.
Belters are licensed to use nukes. They use these nukes to dig out fabulous riches. They have no problems with dumping these riches on your planet to derail your economy. Whatever you base your exchange rate on, they'll find it and drop it on you, possibly for free. Of course this did them little good with the Borstenites. They could drop a gold asteroid (gently, they weren't monsters) on them but it would do little harm to their economy which was based on services and work credits for same and there was no way for them to drop a bunch of masseuses or concierges or factors or call girls on the Landing.
The nukes remained and the belters could use them on the pirates. Thus pirates did not bother belters by and large.
After the belters had enough of the ground pounders double charging them they used a couple of nukes on a few of the dirty snowball asteroids and nudged them into more sunward orbits. Dirty snowballs contain water which can be processed into liquid hydrogen and a merchant ship could usually make a run to an asteroid in 12 hours or less. They could get refined fuel there from a belter running a small station. They could get it under cost.
The Borstenites were somewhat put out by this to say the least.
The economic status quo was in danger!
But piracy saved the day. As I said pirates hate having to actually work for their booty. Running over to a small station on an advertised asteroid was pretty easy. Shooting at tanker shuttles and grabbing their cash, then stealing their fuel and leaving was pretty low risk. The shuttles had to have a regular schedule to be available for the merchants after all. The belters did nuke a pirate ship or two but it cost them a kamikaze shuttle and a fuel depot. Those were uneconomical losses.
The belters were stuck. The local government couldn't be blamed for the pirate attacks and didn't have the resources to create an in system patrol. The belters could have to help pay to form such a patrol, guard their own stations or get out of the fuel depot business. The belters decided they'd had their fun and pulled out of the operation. They sold the sites. To the pirates.
The pirates had their fuel. They mostly left the traders in this system alone and hit them in the surrounding systems earlier or later on their route. The belters had made a profit from their fuel stations, could use them themselves, and even rent shuttles to them or sell excess fuel. The traders had reasonable losses to the pirates who were very careful not to harm crew or ships given their cooperation they also wanted the merchants to buy their fuel.
Like I said there were always places a pirate could get fuel and repairs. There will always be pirates.