All the oxides and hydroxides of metals are basic in nature.
Magnesium oxide is also basic in nature and is a water insoluble base.
When a dilute acid reacts with a base it forms salt and water because the acidity and basicity of the acid and base respectively neutralise each other.This process is known as neutralisation reaction.
When MgO reacts with HCl it forms MgCl2 and water.
In equation form
MgO + 2HCl — MgCl² + H2O