The main problem, as far as TeX's approach to typesetting is concerned, is that the contents of the \left...\right chunk form a "mathinner" math atom that can never be line-broken.
The first order of business, is to replace
$\left.(\ce{Mg^2+}-\ce{PO4^2-})\right/\ce{HNO3-}$
with either
$\bigl(\ce{Mg^2+}-\ce{PO4^2-}\bigr)\big/\ce{HNO3-}$
or, even more simply,
$(\ce{Mg^2+}-\ce{PO4^2-})/\ce{HNO3-}$
in order to avoid creating a mathinner atom.
The second issue is that TeX, by default, won't allow line breaks at arbitary locations inside an inline-math expression. In particular, TeX won't allow line breaks immediately before - and + tokens. This can be adressed by inserting an \allowbreak directly immediately before -\ce{PO4^2-}.

However, this still isn't great, as the \ce{Mg^2+} term protrudes noticeably into the right-hand margin. This issue is most easily fixed -- unless you employ XeLaTeX -- by loading the microtype package, can adjust the inter-word spacing of characters as needed. I added "unless you employ XeLaTeX" because microtype works best under pdfLaTeX and LuaLaTeX.

\documentclass{article}
\usepackage{mhchem}
\usepackage{lipsum}
%\usepackage{microtype} % uncomment as needed
\begin{document}
fsadjlllllllllllllllllllllllllllllllllllllllllllsafddddddddddddddddddddddddlllllll $\left.(\ce{Mg^2+}-\ce{PO4^2-})\right/\ce{HNO3-}$
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus.
fsadjlllllllllllllllllllllllllllllllllllllllllllsafddddddddddddddddddddddddlllllll $(\ce{Mg^2+}-\ce{PO4^2-})/\ce{HNO3-}$
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus.
fsadjlllllllllllllllllllllllllllllllllllllllllllsafddddddddddddddddddddddddlllllll $(\ce{Mg^2+}\allowbreak-\ce{PO4^2-})/\ce{HNO3-}$
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus.
\end{document}
\leftand\rightinstruction had to be in one line (ii) your equation you can write as$(\ce{Mg^2+}-\ce{PO4^2-})\big/\ce{HNO3-}$\par– Zarko May 18 '22 at 04:07\big/, there is a-out of line. How to resolve this problem? – Y. zeng May 18 '22 at 04:27\middleinstead of\bighere, asmiddlewould increase the height as it needs. – Y. zeng May 18 '22 at 04:51-is out of the line: you give no maneuverability to the typesetting machine: there is only one srtetchable/shrinkable space just before math. If this math is moved to the second line then this single space must be removed and the first line is underfull. The first breakpoint in the math is after the minus operator, but the line is overfull in such case. There is no third possibility. – wipet May 18 '22 at 05:34\leftand\right, the slash is too short. – Y. zeng May 18 '22 at 07:32