The Eucharist is a divine gift bestowed upon us by our Heavenly Father. And because it is a gift, the state of your soul matters greatly to our relationship with God when receiving this gift.
Receiving the Eucharist is not a right. It is not your right or my right. It is always a gift. And when we receive it worthily, we are given eternal life. But if we receive that gift unworthily, as the scriptures say, we eat and drink condemnation upon ourselves. If we eat and drink Holy Communion in conscious of mortal sin, Saint Paul says we are guilty of the body and blood of the Lord. Meaning his murder is on our hands.
The Catholic church has always taught that regardless of what the mortal sin is, and you are conscious of that sin, you may not receive Holy Communion until you first go to confession. Otherwise, you are doing what Saint Paul said of eating and drinking condemnation upon yourself.
Pope Francis has said very clearly that the Eucharist is not a reward for perfection or being a spiritual superhero. It is medicine for the sick, but it is not medicine for the dead. And anyone guilty of a mortal sin, is cut off from the Lord. We must first go to confession. When it comes to menial sins, we can continue to approach the Lord in confidence and hope knowing that the Eucharist is medicine for the sick.
However, a priest can and sometimes must withhold communion. However, denying a Catholic communion should never be done without due prayer and discernment. It should never be done for any reason other than the action is understood as necessary for the good of all the faithful as well as for the good of the person being denied communion.