It is legal but it also depends on the platform you purchase them. If you buy YouTube comments that come from real people, that is fine. But If you buy comments generated by different bots or software that is against YouTube policies.