How to update the node status?
To set the status you can use the setPublished() method:


  public function Node::setPublished
  
  Sets the published status of a node..
  
  Parameters
  
  bool $published: TRUE to set this node to published, FALSE to set it
  to unpublished.


In your case:

$node = \Drupal\node\Entity\Node::load($nid);
$node-&gt;set("body", 'New body text');
$node-&gt;set("field_name", 'New value');
$node-&gt;setPublished(TRUE);