Most airlines use Timatic to check visa and transit rules. For the sake of this answer we will assume that this is a single booking, you have a case where Timatic clearly says "travel is ok", and that the airline misread or misinterpreted what Timatic said.
Is the airline obligated to provide compensation in such cases?
That depends very much on the applicable legislation (which in itself can be tricky to determine). In the EU, EC216 should be applicable. The US has legislation for compensation if you are "involuntarily denied boarding" for oversold flights (https://www.ecfr.gov/current/title-14/chapter-II/subchapter-A/part-250/section-250.5), but it's unclear if that would also be applicable to "involuntarily denied boarding" because of paperwork issues.
Does a trip cancellation insurance cover such cases?
Again, that will depend on the terms and exclusions of the specific insurance.
The main problem here is the following: if your situation is cut and dry in Timatic, than the likelihood of being denied boarding is miniscule. However, visa rules are notoriously complicated and if you are denied boarding its mostly because the rules are ambiguous, unclear, or open to interpretation.
In most cases the airline will drag their feet, claiming every possible excuse or interpretation of the rules. Even if you are technically entitled to compensation, you may have to drag them into court before they actually pay up. Many airlines routinely deny EC261 claims, even if they are fully justified.
Chances are that most airline will offer a refund and/or travel credit and maybe a few extra miles or points but anything beyond that would require significant work, effort, time and persistence.