Matthew 5 records the part of Jesus’ Sermon on the Mount known as the Beatitudes. Verse 4 says, "Blessed are they who mourn, for they shall be comforted." It is important to remember that this portion of Jesus’ teaching was directed toward His closest friends, not the general population (verse 2). We cannot pull one or two verses from the whole and build a theology around them. This sermon was a collection of truths designed to prepare His followers for His kingdom, which involved a lifestyle radically different from the world’s.
In the Bible, blessed usually means "happy." But in the context of Matthew 5, blessed most likely indicates "an enviable state." When a person has acquired good fortune, we call him “blessed.” In the Beatitudes, Jesus calls some people “blessed” who appear to be quite the opposite. People who “mourn” don’t seem to be “blessed,” according to most other people. Jesus is contrasting the world’s idea of happiness with true blessedness—spiritual prosperity—which comes from a right relationship with God.
The term mourn means “to experience deep grief.” In keeping with His theme of spiritual blessedness, Jesus seems to indicate that this mourning is due to grief over sin. The people who agree with God about the evil of their own hearts can attain an "enviable state of blessedness," due to the comfort they receive from communion with the Holy Spirit. Jesus called the Holy Spirit the Comforter (John 14:16, 26; 15:26; 2 Corinthians 1:4). The Spirit comforts those who are honest about their own sin and humble enough to ask for forgiveness and healing. Those who hide their sin or try to justify it before God can never know the comfort that comes from a pure heart, as Jesus talks about in Matthew 5:8 (cf. Proverbs 28:13; Isaiah 57:15).
In the Beatitudes, Jesus reminds His disciples that they cannot seek happiness the way the world does. True joy is not found in selfish ambition, excuses, or self-justification. An enviable state of blessedness comes to those who mourn over their own sin. "These are the ones I look on with favor: those who are humble and contrite in spirit, and who tremble at my word" (Isaiah 66:2). When we agree with God about how bad our sin is, repent of it, and seek His power to walk away from it, Jesus promises comfort from the Holy Spirit. The kind of "mourning" that leads to repentance is truly blessed (2 Corinthians 7:10). Repentance results in forgiveness and cleansing from God (Psalm 30:5). When we have trusted in Jesus as our personal substitute for sin, we no longer stand condemned (Romans 8:1). Rather than wallow in guilt and shame, we realize that we stand justified before God (2 Corinthians 5:21; Galatians 3:24). Those who learn to mourn over their own sin find the heart of God. And intimate fellowship with God is the very foundation of true happiness.