A young man attempted to stab his father to death to protect his nephews from abuse and neglect, a court has been told.