Replacing a hub does not mean replacing the spokes. Hub flange sizes are pretty standard. If you have for example a Shimano rear rim brake 135mm freehub for 36 spoke holes, you can usually put another Shimano rear rim brake 135mm freehub and use the same length spokes.
If the spokes have been time-tested, they are better than new, since a new spoke may occasionally (although rarely) have material issues, resulting in some spokes failing early. Your spokes have demonstrated that they have no material issues, if you pick new spokes you can't be certain of that.
However, if hub bearings have failed this does not automatically mean the hub has met its end of life.
If the hub is a loose ball bearing hub like what Shimano sells, it may be that the bearings just need tightening. Check if this is the case and while you're at it, disassemble the hub and look at the quality of cups, cones, bearing balls and replace old grease with new.
It may also be the case some bearing balls have failed. If this is the case, you just put a new equal number of balls in. If there's a ball retainer, it may be replaced with a suitable number of bearing balls of the same size, but assembly without retainer is bit trickier (although not too difficult).
It's also possible bearing cones have failed. In some cases, you may find a replacement cone although it has to be compatible with the old hub, not all cones are compatible.
If a bearing cup has failed, it may be replaced too although you will require some special maybe improvised tools to do that. The cups are press fit. However, the only guarantee of a suitable replacement cup is by buying a new identical hub and cannibalizing it for the bearing cups. That requires less work however than a wheel rebuild so it may be worth it.
If the hub is a cartridge bearing hub, you may replace the cartridge bearings with identical ones. The bearing cartridges are standard parts, replacement parts are very easy to find, but replacing those bearings requires specialized tools, they are press fit.
If the hub is a cup&cone hub with a failed cup or cone and either a replacement cup or cone cannot be found, then in that case the only option is to replace the entire hub. You may reuse the rim always (assuming you selected the same number of spokes for the new hub), and spokes if the new hub has approximately the same flange specifications.
Keep in mind that if you buy an entire new wheel, a human or machine has to build it from the scratch. If it's human who builds the wheel, you're not saving anything by buying an entire new wheel instead of removing the old hub and replacing with the new hub, since in that case you have to pay for new spokes and new rim.
If you find a new machine built wheel, that could save some money, but beware: most machine built wheels are poorly built, so it's very common for heavyweight riders to cause a total and complete loss of tension in the entire wheel, requiring a human to fix it. If you're not heavier than 70 kg, then you may find that some machine built wheels may be acceptable.