Q:

What should the rarity rating be for this homebrew Healing Brick?

I read about this item on reddit (with a different name) a while ago and planned to implement this in my campaign, but I'm unsure what its rarity should be.

Healing Brick
As an action, make either melee or ranged attack roll against target. It is treated as improvised weapon (1d4+STR dmg) with 20/60 range. On a hit, target is healed by 2d4+2 HP, then takes the damage from the attack. On a hit or a miss, the brick loses its magic.

The main thing I'm concerned about is being able to wake knocked out allies from afar, without exposing the user to danger.
Should this item be common like a Healing Potion? Or it should have a higher rarity?

A:

Common is probably the appropriate Rarity for this item
This object has one advantage over a Potion of Healing, and two Disadvantages over a Potion of Healing. The advantage is that it can be used at range—20 feet with a normal attack roll, 60 feet with a disadvantaged attack roll. The disadvantage, as implied by my previous sentence, is that the brick has a chance of failure proportional to how strong your ally's armor is—and this chance does not diminish just because you're in melee/Potion range. And even if the hit successfully lands, there's a non-trivial chance that the damage from the brick being an Improvised Weapon will result in the character taking more damage than what they were healed for.
So if you're in a situation where you need to desperately ensure an ally doesn't die after taking a blow that put them unconscious, this item is going to be a risk even in melee range. In terms of power level (or rarity), it shouldn't be above a Potion of Healing, and maybe arguably is behind it.

A:

Common.
This item heals the same amount as a Healing Potion, another common consumable.

It can be used at range
It can also miss (especially with high AC allies)
Plus, the range is only 20 feet or disadvantage.
If you use this on an unconscious ally, the target will be prone and you will have disadvantage unless you're in melee range
If you use this on an unconscious ally, you have advantage if you're in melee range

In fact, since the brick also does damage (as I've realized from the OP's comments), a melee attack heals on average 2HP on an unconscious ally, and might leave him unconscious again as it crits for 2d4+STR damage. To be honest, I think the item doing damage as well as healing seems to make it useless. I would just leave it with the healing part. Doing damage, it feels like it's only worth it to use if you're a DEX character with multiple attacks, and even then only if there is someone nearby with an actual Healing Potion ready, if you happen to miss.
If you main concern is

being able to wake knocked out allies from afar, without exposing the user to danger.

then it shouldn't be a concern. When you use this brick, it is in fact the unconscious PCs that should be concerned with being exposed to danger. Your mobs now have less PCs to worry about and, if the conscious PCs are hiding behind pillars to heal their comrades without exposing themselves to danger, your mobs have the advantage anyway.

A:

It should probably be common
The ability to heal at range is no minor thing. It can seriously alter your tactics in battle, and turn the tide in your favor. That being said, the effect you are attempting to create is similar to a 1st level spell: Healing Word.

Healing Word: A creature of your choice that you can see within range [60 feet] regains hit points equal to 1d4 + your spellcasting ability modifier. (PHB, p. 250)

The Dungeon Masters Guide suggests that a single use item that permits you to cast a first level spell (such as a Spell Scroll of Healing Word [DMG, p. 200]) should have a rarity of common. 
Now, there are some differences between your proposed item and a Spell Scroll of healing word. For one thing, martial classes would be able to use this brick, and it could be used without the possibility of being undone via a Counterspell. But these benefits are effectively countered by its disadvantages (you won't use your proficiency bonus to attack with it, and most unconscious targets are prone, giving you disadvantage on ranged attacks against them, which means you won't gain full advantage granted by the unconscious condition). As such, I believe this item is well balanced by a common rarity. 

