Magento 2: How to update order status programmatically in custom module?

You can do it like following way

declare below namespace

use Magento\Sales\Model\Order;

$orderId = 1;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('\Magento\Sales\Model\Order') ->load($orderId);
$orderState = Order::STATE_PROCESSING;
$order->setState($orderState)->setStatus(Order::STATE_PROCESSING);
$order->save();

Hope this helps


Order state update

To update the order state and and status pro-grammatically in order define the status and state in this format. Initiate order object in the construct function and use that order object in the custom function to update it. To update order state programmatically in model, get order object from the construct function.

public function __construct(
    \Magento\Sales\Model\Order $order
){
    $this->order = $order;
}
public function updateorder(){
    $order = $this->order;
    $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true);
    $order->setStatus(\Magento\Sales\Model\Order::STATE_PROCESSING);
    $order->addStatusToHistory($order->getStatus(), 'Order processed successfully with reference');
    $order->save();
}

New order email

$orderid = '10000000';
$order = $this->_objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId($orderid);
$this->_objectManager->get('Magento\Sales\Model\Order\Email\Sender\OrderSender')->send($order);

Since load() and save() are deprecated now (because :)

* @deprecated 100.1.0 because entities must not be responsible for their own loading.
* Service contracts should persist entities. Use resource model "load" or collections to implement
* service contract model loading operations.

I used the OrderRepositoryInterface to load and save the order :

use Magento\Sales\Api\OrderRepositoryInterface;

public function __construct(
    OrderRepositoryInterface $orderRepository,
    ...
) {
    $this->orderRepository = $orderRepository;
}

...
$order = $this->orderRepository->get($orderId);
$order->setState(\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW);
$order->setStatus(\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW);

try {
    $this->orderRepository->save($order);
} catch (\Exception $e) {
    $this->logger->error($e);
    $this->messageManager->addExceptionMessage($e, $e->getMessage());
}

Hope it helps