Modern cruise ships for the most part are equipped with medical facilities and staff of high standard, certainly higher than most destinations they set out for. It's mainly because that's regulation.
If a passanger falls seriously ill however, those facilities are merely the temporary means to keep you alive until the cruise ship arrives at the nearest port where it leaves you in the capable hands of local healthcare.
As it turns out, most of the time it means they kick you out of the ship to die. Because local healthcare of the garden variety is for the most part not capable of keeping a patient alive, unlike the shipborne medical facilities.
If you have the particular misfortune to be befallen of some sickness that looks anything like it could infect fellow passengers, no matter if serious or not, you might also be entirely on your own. Because things like quarantine facilities are not regulation. Because decontaminating a room is expensive, you'll likely spend the duration to the next port in a bare cell that's easy to disinfect afterwards. Should you die in there, they'll make it look like they cared for you, and if not, well they acted by the book.
The reason this macabre theatre happens is because of this. Should a passanger die on your ship, it's a huge headache for the cruise operator involving inspections, tons of paperwork, possibly a being forced to stay in port, missing a schedule and so forth. But if you can shuffle a passenger off to die somewhere else, it's no longer your problem.
There is just one thing worse for the cruise operator than having somebody die on his ship. It would be for multiple people to die, or many to fall sick, for which the hassle would be exponentially worse than a single dead passanger.