Is it legal to do this? Can't I just take out policies on people I know with underrated or misclassified health problems and make money?
In the UK you must have an "insurable interest" in the thing you want to insure. This means you would suffer a financial or other kind of loss if the thing were lost or damaged. You can't take out insurance on things in which you don't have an insurable interest - or the policy would be invalid if you did.
So you can get life insurance for your spouse and home insurance for your home, but not life insurance for your neighbour's spouse or home insurance for their home.
(In the UK the person to be insured could assign their policy to or place it in trust with named beneficiaries.)
Also you must declare pre-existing conditions on application for life insurance, else the policy does not cover them or is invalidated - either way you have wasted your money.