You can do this through simulation, but that might not be very convenient if you are writing a backend. I would start with the following method:
- keep track of which hand is the best before any cards are dealt (AT > KQ, 33 > 22, 55 > AK)
- calculate any possible outs that the worse hand could hit to become the best hand, including any possible straights or flushes
- start each of the worse hands at 0% and the best hand at 100%, then for each out the worse hands have, add the probability that they will hit that out in the next 5 cards to their total while subtracting that from the total of the best hand.
With more than 2 hands all-in it gets a little murky doing it this way, you will have to split up the probability subtraction part among multiple hands. You can easily experiment and adjust using tools like pokerstove that do run large numbers of simulations and compare that to your results.
Also keep in mind that because there are no draws preflop, you can hard code some percentages for a hand to hit a flush/straight. With 2 suited cards there is ~6% chance of hitting a flush by the river. With non-connected cards there is a probability of hitting a 4 card straight and connected cards have a constant probability of hitting a straight based on how big the gap between the cards is.