The specific answer always depends on your employer and your exact situation, this article just gives some general information. We recommend speaking to a tax adviser too, as while health insurance is one issue, the more complicated one will usually be your tax situation.
I work on a freelance basis for clients outside of Germany
You're a normal freelancer. See all articles that help you as a freelancer.
I work with an employment contract outside of Germany
In most cases this means that you are considered a freelancer. We recommend doing the following things though:
Check if your contract can be transferred to a German subsidiary
Ask your employer if they can pay the employers contribution of 50% for healthcare that is usual in Germany
If you're from the EU you can sign up for the public system as explained here or expat of full private health insurance. We strongly recommend public or full private in this situation though