To avoid a hard border of course. Since according to you this cannot be avoided unless the UK (or at least Northern Ireland) and Ireland are in the same single market and customs union, it makes sense for Ireland to come out of the EU and be part of a customs union with the UK.
Problem solved.