Primary and secondary pupils in England will learn about relationships, keeping safe online and looking after their mental health as part of compulsory lessons from September next year.